NumPy Poisson Distribution
A Poisson distribution models non-negative event counts with a rate parameter for the stated exposure interval. The parameter is an expected count, not a probability.
How it works
The simple interpretation assumes a suitable stable rate and event process. A toy count of sensor interruptions per observation window illustrates the API without claiming that real interruptions are independent. If the exposure length changes, the expected count must reflect that change. Count variability and the mechanism generating events should be reviewed before selecting a distribution merely because its values are integers.
Run the code
Select Try in playground to preload the complete code into the NumPy editor. Nothing executes on import; choose Run when ready. The first execution loads the local Pyodide runtime and NumPy package. Each ordinary run starts fresh, with no access to this page’s cookies or personal files. In-memory streams and temporary virtual files belong to the runtime, not your PC.
For local work, use a separate virtual environment and run python poisson.py. Download the complete source. The reviewed local environment uses Python 3.12.14 and NumPy 2.5.4; the browser uses Pyodide 0.27.7 with NumPy 2.0.2. Compatible examples are checked in both. See the environment setup. No Apache or database server is required.
Example
import numpy as np
rng = np.random.default_rng(41)
draws = rng.poisson(lam=2., size=50)
print(bool((draws >= 0).all()))
print(draws.dtype.kind in "iu")
print(rng.poisson(lam=0., size=3).tolist())
Expected result
True True [0, 0, 0]
The ordinary sample stays in the count domain and zero expected events gives a deterministic zero boundary. This tests support and parameter meaning without requiring a finite sample average to equal exactly two.
Use NumPy’s official reference for precise contracts, supported versions and numerical limitations.