skfolio.measures
.semi_variance#
- skfolio.measures.semi_variance(returns, min_acceptable_return=None, sample_weight=None, biased=False)[source]#
Compute the semi-variance (second lower partial moment).
The semi-variance is the variance of the returns below a minimum acceptable return.
- Parameters:
- returnsndarray of shape (n_observations,) or (n_observations, n_assets)
Array of return values.
- min_acceptable_returnfloat or ndarray of shape (n_assets,) optional
Minimum acceptable return. It is the return target to distinguish “downside” and “upside” returns. The default (
None
) is to use the returns’ mean.- biasedbool, default=False
If False (default), computes the sample semi-variance (unbiased); otherwise, computes the population semi-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,)
Semi-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,).