Sampling
- sample_from_pmf(pmf, rng)
Sample from a probability mass function.
- Parameters:
pmf (
dict[TypeVar(T),float]) – A dictionary mapping each possible outcome to its probability.- Return type:
TypeVar(T)- Returns:
A random outcome from the probability mass function.
- sample_order_from_pmf(pmf, rng)
Sample a random order from a probability mass function without replacement.
- Parameters:
pmf (
dict[TypeVar(T),float]) – A dictionary mapping each possible outcome to its probability.- Return type:
list[TypeVar(T)]- Returns:
A list containing all outcomes in random order.
- combinations_in_random_order(iterable, r, rng)
Sample random combinations of r elements from an iterable.
- Parameters:
iterable (
Iterable[TypeVar(T)]) – The iterable to sample from.r (
int) – The number of elements to sample.rng (
Generator) – The random number generator to use.
- Return type:
Iterator[tuple[TypeVar(T),...]]