- The Poisson Distribution CDF computes the probability $P(X \le k)$ for a Poisson random variable whose rate parameter $\lambda$ is derived from the...
The Poisson Distribution CDF computes the probability $P(X \le k)$ for a Poisson random variable whose rate parameter $\lambda$ is derived from the min-max normalized price. The Poisson distribution models the number of events in a fixed interval given a constant average rate, making it natural for count-based financial metrics (trade arrivals, tick counts, order flow). The implementation maps normalized price to $\lambda$ via a scale factor, then evaluates the CDF using the identity $P(X \le k) = 1 - P(k+1, \lambda)$ where $P(a, x)$ is the regularized lower incomplete gamma function. This reuses the same Lanczos log-gamma and series/continued-fraction infrastructure as GAMMADIST.
## Historical Context
The Poisson distribution was derived by Simeon Denis Poisson (1837) as a limiting case of the binomial distribution when the number of trials is large and the success probability is small. Ladislaus Bortkiewicz (1898) famously demonstrated its applicability by modeling deaths from horse kicks in the Prussian army, establishing it as the canonical distribution for rare events.
In financial markets, Poisson processes model trade arrivals in market microstructure theory (O'Hara, 1995), jump events in Merton's jump-diffusion model (1976), and order book dynamics. The CDF form used here provides a probability-weighted indicator: for a given threshold $k$ and price-derived rate $\lambda$, the output answers "what is the probability that a Poisson process with rate proportional to the normalized price would produce at most $k$ events?"
When the normalized price is low (near 0), $\lambda$ is small and the CDF is close to 1 (almost certainly $\le k$ events). When normalized price approaches 1, $\lambda$ is large and the CDF drops (many events expected, exceeding $k$ becomes likely). The `lambda_scale` parameter controls the dynamic range: higher values cause broader CDF variation across the $[0, 1]$ normalized range.
## Architecture and Physics
The computation follows a three-phase pipeline:
**Phase 1: Min-max normalization** scans `period` bars for extrema, maps the current source to $x \in [0, 1]$, then derives the rate: $\lambda = \max(0, x \cdot \text{lambda\_scale})$.
**Phase 2: Degenerate case** handles $\lambda = 0$ by returning 1.0 (Poisson with rate 0 puts all mass at $X = 0$, so $P(X \le k) = 1$ for any $k \ge 0$).
**Phase 3: Gamma function identity** uses the well-known relationship between the Poisson CDF and the regularized incomplete gamma function:
where $P(a, x)$ is the regularized lower incomplete gamma and $Q$ is its complement. The implementation delegates to `gammaP()`, which internally selects between series expansion (for $\lambda < k + 2$) and Lentz continued fraction (otherwise).
**Threshold parameter $k$**: Integer-valued, controls the step function shape. Small $k$ (0-2) creates a steep CDF that drops rapidly as $\lambda$ increases. Large $k$ (10+) creates a gentle curve that stays near 1.0 until $\lambda$ significantly exceeds $k$.
## Mathematical Foundation
The Poisson distribution with rate $\lambda > 0$ has PMF:
where $\Gamma(a, x) = \int_x^\infty t^{a-1} e^{-t}\,dt$ is the upper incomplete gamma function and $P(a, x) = \gamma(a, x)/\Gamma(a)$ is the regularized lower incomplete gamma.