skfolio.utils.stats.rand_weights#

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

Produces n random weights that sum to one from a 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.

seedint or None, default=None

Seed for reproducibility. If None, use an unseeded generator.

Returns:
weightsndarray of shape (n, )

The vector of weights.