Python: Poisson, Exponential, and Gamma Distributions
Recreate three distribution plots in Python: Poisson counts, exponential waiting times, and gamma shapes, with the rate-versus-scale convention made explicit.
So I just plotted the distributions using the parameters from the Wikipedia figures. Literally just the plots.
I didn’t bother with the whole pulling-random-variables-out-and-cross-checking-them-against-the-mean-and-variance thing this time… heh heh heh.
It’s been a while since I sat down and did real integration lol — kinda nostalgic, honestly…..
And that cursed gamma integral, man — apparently we hadn’t met in ages, and now it’s Chuseok, the Korean harvest holiday, so we’re having a reunion lololol. Hella familiar.
I’ll do the same thing for the rest of the distributions, and once everything’s wrapped up I’ll holler at you again~
Derivation of the Poisson Distribution [ Statistics Basics I Studied #2 ] Derivation of the Exponential Distribution [ Statistics Basics I Studied #3 ] Derivation of the Gamma Distribution [ Statistics Basics I Studied #4 ]
Poisson: how many events?
For the first picture, the horizontal axis is an integer count, not elapsed time. The Poisson parameter $\lambda$ is the expected number of events in the chosen interval, and $P(N=n)=e^{-\lambda}\lambda^n/n!$. The three curves use $\lambda=1,4,10$. As $\lambda$ grows, the mass moves right and spreads out: both the mean and variance equal $\lambda$. The connecting lines are a visual guide; probability belongs to the dots at integer counts.

(Figure/parameter source: Korean Wikipedia — Poisson distribution .)
Exponential: how long until the next event?
Now the horizontal axis is a nonnegative waiting time. The parameter $\lambda$ is a rate, and the density is $f(t)=\lambda e^{-\lambda t}$. The plotted rates are $0.5,1,1.5$. A larger rate means a shorter average wait, $E[T]=1/\lambda$ — so the curve starts higher and drops faster. A density’s height isn’t the probability of one exact time; probability comes from the area over a time interval.

(Figure/parameter source: Korean Wikipedia — exponential distribution .)
Gamma: change the shape, change the scale
The legend uses shape $k$ and scale $\theta$, with $f(t)=t^{k-1}e^{-t/\theta}/[\Gamma(k)\theta^k]$ for $t>0$. Here $E[T]=k\theta$ and $\operatorname{Var}(T)=k\theta^2$. When $k=1$, this is the exponential distribution with rate $1/\theta$; for integer $k$, it also describes waiting for $k$ events of a constant-rate Poisson process.
The pairs below are $(k,\theta)=(1,2),(2,2),(3,2),(5,1),(9,0.5)$. Keeping $\theta=2$ and increasing $k$ moves the peak right. The last two curves change both parameters, so don’t read them as a shape-only comparison!

(Figure/parameter source: Korean Wikipedia — gamma distribution .)
Recreate the curves
Here’s the actual plotting code, then! Install numpy, scipy and matplotlib if needed, and run this in a Python script or notebook. These are analytical PMFs/PDFs, not simulated histograms. The one convention worth watching is scale=1/rate for the exponential — SciPy’s scale is not $\lambda$.
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import poisson, expon, gamma
fig, axes = plt.subplots(1, 3, figsize=(15, 4))
counts = np.arange(0, 21)
for lam in (1, 4, 10):
axes[0].plot(counts, poisson.pmf(counts, mu=lam),
marker="o", markersize=3, label=f"mean={lam}")
axes[0].set(xlabel="Event count n", ylabel="P(N=n)", title="Poisson")
waiting_time = np.linspace(0, 5, 500)
for rate in (0.5, 1, 1.5):
axes[1].plot(waiting_time, expon.pdf(waiting_time, scale=1/rate),
label=f"rate={rate}")
axes[1].set(xlabel="Waiting time", ylabel="Density", title="Exponential")
time = np.linspace(0, 20, 800)
for shape, scale in ((1, 2), (2, 2), (3, 2), (5, 1), (9, 0.5)):
axes[2].plot(time, gamma.pdf(time, a=shape, scale=scale),
label=f"k={shape}, theta={scale}")
axes[2].set(xlabel="Waiting time", ylabel="Density", title="Gamma")
for ax in axes:
ax.legend()
ax.grid(alpha=0.25)
fig.tight_layout()
plt.show()
One quick check before trusting a plot: gamma.pdf(time, a=1, scale=2) and expon.pdf(time, scale=2) should coincide. Same distribution, two names!
The API conventions are documented in SciPy’s Poisson , exponential , and gamma references. For the derivations behind the pictures, use the three earlier posts linked above.
Questions or corrections?
Did a step lose you, or does a number look off? Email me or use the contact page. Include the note title and the step or figure you mean.
Feedback goes to me privately by email; it is not posted as a public comment.