Random variables & distributions
Step 14 of 18 in Foundations · Concept · Easy
A distribution describes how likely each outcome is. Bernoulli, binomial, Gaussian and Poisson cover most of what you will model.
The lesson
A random variable is a number decided by chance. Its distribution says how likely each value is. For countable outcomes that is a PMF, P(X = k), and the values sum to 1. For continuous outcomes it is a PDF: probability is the area under the curve, and the total area is 1.
Four distributions cover most modelling. Bernoulli(p): one yes or no, 1 with probability p. Binomial(n, p): the number of yeses in n independent tries, with mean n·p. Poisson(λ): how many events land in a fixed window at an average rate λ; mean and variance are both λ. Normal(μ, σ²): the bell curve; about 68% of values fall within 1σ of the mean and 95% within 2σ.
- Arrangements with 2 heads: HHT, HTH, THH. That is 3.
- Each has probability (½)³ = 1/8.
- 3 × 1/8 = 3/8
rng = np.random.default_rng(0)
rng.binomial(10, 0.3, size=10_000)
rng.poisson(4, size=10_000)
rng.normal(0, 1, size=10_000)Common mistake. The height of a PDF is a density, not a probability, and it can be greater than 1. For a continuous variable the chance of any exact value is 0. Only intervals have probability.
Check yourself
X is Binomial with n = 20 and p = 0.3. What is its mean?
Show the answer
6. n·p = 20 × 0.3 = 6.
Which distribution fits the number of support tickets arriving in an hour?
- Poisson
- Bernoulli
- Normal
Show the answer
Poisson. A count of events in a fixed window at some average rate is the Poisson's job. Bernoulli is a single yes or no; a Normal allows negative and fractional values.
What is P(exactly 1 head in 4 fair flips)?
Show the answer
0.25. 4 arrangements, each (½)⁴ = 1/16. 4/16 = 0.25.
Build it
Sample and compare
Sample 10,000 values from Bernoulli, binomial, Poisson and normal; plot histograms against their theoretical PMF/PDF.
Done when: Histograms overlay their curves.
Resources
- Wikipedia: Probability distribution Article
- Seeing Theory Article
- StatQuest Video
- Think Bayes (free book) Book
Earn this star
On the map, your answers are marked and you log what you built. Finish the step and its star lights.
Open this step on the map