skfolio.measures
.variance#
- skfolio.measures.variance(returns, biased=False, sample_weight=None)[source]#
Compute the variance (second moment).
- Parameters:
- returnsndarray of shape (n_observations,) or (n_observations, n_assets)
Array of return values.
- biasedbool, default=False
If False (default), computes the sample variance (unbiased); otherwise, computes the population variance (biased).
- sample_weightndarray of shape (n_observations,), optional
Sample weights for each observation. If None, equal weights are assumed.
- Returns:
- valuefloat or ndarray of shape (n_assets,)
Variance. If
returns
is a 1D-array, the result is a float. Ifreturns
is a 2D-array, the result is a ndarray of shape (n_assets,).