skfolio.utils.stats.rand_weights#

skfolio.utils.stats.rand_weights(n, zeros=0)[source]#

Produces n random weights that sum to one from an uniform distribution (non-uniform distribution over a simplex)

Parameters:
nint

Number of weights.

zerosint, default=0

The number of weights to randomly set to zeros.

Returns:
weightsndarray of shape (n, )

The vector of weights.