distributions.Poisson
Poisson distribution implementation.
Usage
distributions.Poisson()Used to simulate number of events that occur in an interval of time. E.g. number of items in a batch.
This class conforms to the Distribution protocol.
Sources:
Law (2007 pg. 308) Simulation modelling and analysis.
Methods
| Name | Description |
|---|---|
| __init__() | Initialize a Poisson distribution. |
| sample() | Generate random samples from the Poisson distribution. |
__init__()
Initialize a Poisson distribution.
Usage
__init__(rate, random_seed=None)Parameters
rate: float-
Mean number of events in time period.
random_seed: Optional[Union[int, SeedSequence]] = None- A random seed or SeedSequence to reproduce samples. If None, a unique sample sequence is generated.
sample()
Generate random samples from the Poisson distribution.
Usage
sample(size=None)Parameters
size: Optional[Union[int, Tuple[int, …]]] = None-
The number/shape of samples to generate:
- If None: returns a single sample as an integer
- If int: returns a 1-D array with that many samples
- If tuple of ints: returns an array with that shape
Returns
Union[int, NDArray[np.int_]]-
Random samples from the Poisson distribution:
- A single integer when size is None
- A numpy array of integers with shape determined by size parameter