stochastic_universal_sampling#

pybrops.core.random.sampling.stochastic_universal_sampling(a, p, size=None, rng=None)[source]#

Perform stochastic universal sampling.

Parameters:
  • a (numpy.ndarray) – Array of shape (n,) containing element from which to sample.

  • p (numpy.ndarray) –

    Contribution probability array of shape (n,).

    Where:

    • n is the number of elements.

    Restrictions:

    • Values are restricted to \([0,\infty]\).

    • Sum of values in vector must be \(>0.0\).

  • size (Integral, Tuple[Integral,...]) – Target output size.

  • rng (Generator, RandomState, None) – Random number source. If None, use default rng.

Returns:

out – Sampling of items from a.

Return type:

numpy.ndarray