skfolio.measures.semi_deviation#

skfolio.measures.semi_deviation(returns, min_acceptable_return=None, sample_weight=None, biased=False)[source]#

Compute the semi deviation (square root of the second lower partial moment).

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-deviation (unbiased); otherwise, computes the population semi-seviation (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-deviation. If returns is a 1D-array, the result is a float. If returns is a 2D-array, the result is a ndarray of shape (n_assets,).