Gamma Distribution¶
Formula¶
\[
f(x)=\frac{\beta^\alpha}{\Gamma(\alpha)}x^{\alpha-1}e^{-\beta x},\quad x\ge 0
\]
Plot¶
fn: x*exp(-x)
xmin: 0
xmax: 10
ymin: 0
ymax: 0.5
height: 280
title: Gamma PDF (alpha=2, rate=1)
Parameters¶
- \(\alpha>0\): shape
- \(\beta>0\): rate (one common parameterization)
- \(\Gamma(\alpha)\): gamma function
What it means¶
A flexible positive-valued distribution that generalizes the exponential distribution.
What it's used for¶
- Waiting times for multiple Poisson events.
- Bayesian priors for rates/precisions.
Key properties¶
- Mean \(\alpha/\beta\), variance \(\alpha/\beta^2\) (rate form).
- Exponential is the special case \(\alpha=1\).
Common gotchas¶
- Scale-vs-rate parameterization varies across sources.
- Shape near \(<1\) changes density behavior near zero.
Example¶
The waiting time until the 3rd Poisson event follows a Gamma distribution.
How to Compute (Pseudocode)¶
Input: distribution parameters and query values (for PMF/PDF/CDF or moments)
Output: distribution quantities
validate parameters
for each query value x (or count k):
evaluate the PMF/PDF/CDF formula from the card
optionally compute moments/statistics from known closed forms or by summation/integration
return the requested values
Complexity¶
- Time: Typically \(O(q)\) for \(q\) query values once parameters are known (assuming constant-time formula evaluation per query)
- Space: \(O(q)\) for output values (or \(O(1)\) for a single query)
- Assumptions: Parameter estimation/fitting cost is excluded; numerical special-function evaluation can affect constants for some families