rDiscrete¶
- rDiscrete(*args)¶
Realization of a bounded integral discrete distribution.
- Parameters:
- probabilitiessequence of float
The probabilities of the discrete distribution , where and .
- sizeint
The number of realizations to generate.
- Returns:
- realizationsint or
Indices
The realizations of the discrete disctribution.
- realizationsint or
Notes
This method implements the alias method as described in [devroye1986], Chapter 3. It has an optimal space complexity of and runtime CPU complexity of .
Examples
>>> import openturns as ot >>> ot.RandomGenerator.SetSeed(0) >>> r = ot.DistFunc.rDiscrete([0.2, 0.3, 0.5]) >>> r = ot.DistFunc.rDiscrete([0.2, 0.3, 0.5], 10)