pandemia.random_tools
Module Contents
Classes
Wraps the python random classes as an abstraction layer over them, |
Attributes
- pandemia.random_tools.log
- pandemia.random_tools.Probability
- pandemia.random_tools.T
- class pandemia.random_tools.Random(seed=None)
Wraps the python random classes as an abstraction layer over them, and offers a number of convenience methods.
- gammavariate(alpha: float, beta: float) Probability
Sample gamma distributed random variable with shape parameter alpha and scale parameter beta.
- expovariate(lambd: float) Probability
Sample exponentially distributed random variable with mean 1 / lambda.
- random_randrange(stop: int) int
Random randrange function.
- binomial(size: int, prob: float) int
Random binomial function.
- randrange_interval(start: int, stop: int) int
Random randrange function.
- random_choice(sequence: Sequence[T]) T
Random choice function.
- random_choices(population: Sequence[T], weights: Sequence[int], sample_size: int) list[T]
Random choices function.
- random_sample(population: Sequence[T], k: int) list[T]
Select k items from the population given.
- random_shuffle(x: MutableSequence[Any]) None
Random shuffle function.
- random_float(x: Probability) float
Return random number between 0 and x.
- multinoulli(problist: Sequence[Probability]) int
Sample at random from a list of n options with given probabilities.
Identical to ‘roulette wheel’ random selection.
Parameters:
- problistlist
A list of n items, each of which is a weight.
Returns:
- indexint
The index number of the item chosen.
- multinoulli_dict(problist_dict: dict[T, Probability]) T
Sample from a key:value dict using weights.
For example, {‘a’: 4, ‘b’: 6} has a 60% chance of returning ‘b’ and a 40% chance of returning ‘a’.
- boolean(probability_true: Probability) bool
Return true with the probability given.