Chooses a random element from an indexed sequence.
Chooses a random element from an indexed sequence.
the type of the elements
the indexed sequence of elements to choose from
the selected element wrapped in a Some
if seq
has at least one element, None
otherwise.
Chooses n random element from a sequence.
Chooses n random element from a sequence.
the type of the elements
the sequence of elements to choose from
the selected elements
Returns a decreasingly ordered stream of n doubles in [0, 1], according to a uniform distribution.
Returns a decreasingly ordered stream of n doubles in [0, 1], according to a uniform distribution. More Info: BENTLEY, SAXE, Generating Sorted Lists of Random Numbers
amount of numbers to generate
ordered stream of doubles
Returns an increasingly ordered stream of n doubles in [0, 1], according to a uniform distribution.
Returns an increasingly ordered stream of n doubles in [0, 1], according to a uniform distribution. More Info: BENTLEY, SAXE, Generating Sorted Lists of Random Numbers
amount of numbers to generate
ordered stream of doubles
Chooses an element of a sequence according to a weight function.
Chooses an element of a sequence according to a weight function.
the type of the elements in the sequence
the pairs (element, probability) to choose from
the selected element wrapped in a Some
if some element was chosen, None
otherwise. Not choosing any element can happen if the weights of the elements do not
sum up to the maximum value of r
.
Chooses an element of a sequence according to a weight function.
Chooses an element of a sequence according to a weight function.
the type of the elements
the elements to choose from
the function that maps elements to weights
the random value used to select the elements. If the default random value is used, the weighted selection uses 1.0 as the sum of all weights. To use another scale of weights, a random value between 0.0 and the maximum weight should be passed.
the selected element wrapped in a Some
if some element was chosen, None
otherwise. Not choosing any element can happen if the weights of the elements do not
sum up to the maximum value of r
.
the Random
instance to which the new methods are provided.
Chooses a random element of a traversable using the reservoir sampling technique, traversing only once the given sequence.
Chooses a random element of a traversable using the reservoir sampling technique, traversing only once the given sequence.
the type of the elements
the elements to choose from
the selected element wrapped in a Some
, or None
if the traversable is empty.
Returns an infinite stream of weighted samples of a sequence.
Returns an infinite stream of weighted samples of a sequence.
the type of the elements
the pairs (element, probability) to choose from
an infinite stream of weighted samples of a sequence.
Returns an infinite stream of weighted samples of a sequence.
Returns an infinite stream of weighted samples of a sequence.
the type of the elements
the elements to choose from
an infinite stream of weighted samples of a sequence.
Implicit class that provides new methods for random number generators.