TL;DR — This is the refresher everything else stands on. A probability is a proportion between 0 and 1, and a risk is exactly that — events divided by everyone. Odds is a second currency for the same chance: events divided by non-events,
odds = p/(1−p), and you convert back withp = odds/(1+odds). A random variable has a mean (its center), a variance (average squared spread), and a standard deviation (spread in the original units). The normal bell curve is the shape most averages take: about 68% of the mass sits within ±1 SD and about 95% within ±1.96 SD — that famous 1.96 is just the point that leaves 2.5% in each tail. When you estimate something from a sample, the estimate wobbles; the size of that wobble is the standard error,SE = SD/√n, which shrinks asngrows. A 95% confidence interval isestimate ± 1.96·SE— and it means the procedure traps the true value about 95% of the time, not that there is a 95% chance the truth sits in this one interval. A p-value is the probability of data at least this extreme if there were truly no effect. Report an estimate with its interval, never a lonely number.
1. Simple explanation
Probability is just a way of counting the future. If something can happen in many ways and you count what fraction of those ways is the one you care about, that fraction — a number between 0 and 1 — is the probability. A risk is the same idea wearing work clothes: take everyone in a group, count how many had the event, divide. Fifteen out of a hundred is a risk of 0.15, or 15%.
Analogy — rainy days in a city. Look back at the last 100 days and count that 15 were rainy. The risk of rain is 15/100 = 15% — rainy days out of all days. But a gambler would not say "15%." They would quote the odds: 15 rainy days against 85 dry ones, 15/85 ≈ 0.18 — "a bit less than one rainy day for every five dry." Same weather, two currencies. Risk is out of everyone; odds is events per non-event. You can always convert one to the other, and knowing both is half of statistics.
Now the second half. You almost never see all the days, or all the patients, or all the users — you see a sample. So your 15% is a guess at the true rain rate, and if you had watched a different 100 days you would have gotten a slightly different number. That built-in wobble is the whole reason statistics exists. The tools below — mean, variance, standard deviation, the bell curve, the standard error, the confidence interval, the p-value — are all machinery for one job: say how much your number could have wobbled, and how sure you are allowed to be.
The three questions this article answers: How do I turn counts into a probability (and into odds)? How much does a sample estimate wobble? And what does "95% confident" actually promise me?
2. Diagram
COUNTS -> PROBABILITY -> ODDS (two currencies for one chance)
15 rainy days out of 100
│
risk p = 15/100 = 0.15 odds = p/(1-p) = 0.15/0.85 = 0.18
▲ │
└──────── p = odds/(1+odds) ◄──┘
A RANDOM VARIABLE and its summary numbers
mean μ = the center (average outcome)
var σ² = average squared distance from the center
sd σ = √var = spread in the ORIGINAL units
THE NORMAL (BELL) CURVE
┌───── 68% ─────┐
┌────────── 95% ──────────┐
───────┼────┬────┬────┬────┬────┬────┼───────
-1.96 -1σ μ +1σ +1.96
(2.5% in the left tail) (2.5% in the right tail)
1.96 = the point that leaves 2.5% beyond it on each side
SAMPLING: your estimate wobbles
true value ●
│ estimate from ONE sample: ○ (near, not exact)
wobble size = STANDARD ERROR SE = SD / √n (shrinks as n grows)
95% CONFIDENCE INTERVAL
estimate ± 1.96 · SE
[────────●────────] run it many times ->
about 95 of every 100 such intervals cover the true value
3. How it works
3.1 Probability, proportion, and risk are the same thing
Before anything else — an event is a COUNT; a probability is a FRACTION. They are different kinds of number, and mixing them up causes most of the early confusion.
Picture 100 days, 15 rainy:
██████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
15 rainy (█) · 85 dry (░) · 100 total
EVENTS = 15 → a COUNT: "how many happened?" (a whole number)
PROBABILITY = 15 / 100 → a FRACTION: "what share of everyone?" = 0.15 = 15% (0 to 1)
The event is the ingredient (how many times it happened); the probability is what you cook from it — events ÷ total. A coin flip makes it obvious: 5 heads in 10 flips → 5 events, but probability 5/10 = 0.5. So whenever you see a probability/risk, it is always "some count, divided by the total."
With that straight, the three words below are just that same fraction seen from different angles. A probability answers "out of all the ways this could go, what fraction is the outcome I care about?" It lives between 0 (never) and 1 (always). A proportion is that same fraction measured on data you already have. A risk is a proportion of people (or days, or trials) who had an event.
| Term | Formula | Reads as | Range |
|---|---|---|---|
| Probability | favorable / total | "chance it happens" | 0 to 1 |
| Risk (a proportion) | events / everyone | "15 of 100 had it" | 0 to 1 |
| Odds | events / non-events | "15 against 85" | 0 to ∞ |
The key move: risk divides by everyone; odds divides by the ones it did not happen to. When the event is rare, the two are almost the same (if only 1 in 1000 rains, dividing by 999 ≈ dividing by 1000). When the event is common they pull apart. That is why a coin flip has risk 0.5 but odds 1.
3.2 Converting between odds and probability
These two formulas are inverses of each other. Memorize one and you have both.
| Direction | Formula |
|---|---|
| probability → odds | odds = p / (1 − p) |
| odds → probability | p = odds / (1 + odds) |
Rainy days: p = 0.15, so odds = 0.15 / 0.85 = 0.1765. Going back: p = 0.1765 / 1.1765 = 0.15. Round-trip lands exactly where it started, because the formulas undo each other. A fair coin: p = 0.5 gives odds = 0.5/0.5 = 1 ("even odds"). This conversion is the doorway to the log scale and to logistic regression, where models predict log-odds because that quantity is unbounded and symmetric.
3.3 Random variables: mean, variance, standard deviation
A random variable is a number whose value depends on chance — tomorrow's rain (0 or 1), a die roll (1–6), a user's session length. We summarize it with three numbers.
| Summary | Symbol | Meaning | Formula (data) |
|---|---|---|---|
| Mean | μ | the center / average | (1/n) Σ xᵢ |
| Variance | σ² | average squared distance from the mean | (1/n) Σ (xᵢ − μ)² |
| Standard deviation | σ | spread in the original units | √variance |
Variance squares the deviations, so its units are weird (dollars-squared, days-squared). Standard deviation takes the square root to get back to plain units, which is why we quote SD, not variance, when describing spread. For an event that happens with probability p (a Bernoulli variable that is 1 or 0), the mean is p and the variance is p(1−p) — a tidy fact we lean on for risks.
3.4 The normal curve and where 1.96 comes from
Add up or average many small independent wobbles and the result piles into a bell curve — the normal distribution. This is not a coincidence you have to trust; it is the Central Limit Theorem, and it is why averages and proportions behave so predictably. The bell has fixed landmarks:
| Interval around the mean | Share of the data |
|---|---|
| ±1 SD | ≈ 68% |
| ±1.96 SD | ≈ 95% |
| ±2.58 SD | ≈ 99% |
Where does 1.96 come from? For a 95% interval you want 5% left over, split evenly into the two tails — 2.5% in each. The point on a standard normal curve that leaves exactly 2.5% beyond it is 1.959964…, which everyone rounds to 1.96. It is not magic; it is just "the cutoff that fences off the middle 95%." Want 99%? Use 2.58 (0.5% per tail). Want 90%? Use 1.645 (5% per tail).
3.5 Sampling and the standard error
You measure a sample, not the whole world, so your estimate is one draw from a cloud of estimates you could have gotten. The spread of that cloud is the standard error (SE) — the standard deviation of the estimate itself, not of the raw data.
SE = SD / √n
The √n in the denominator is the most important fraction in applied statistics. It says precision improves, but slowly: to cut your SE in half you need four times the data; to cut it to a tenth you need a hundred times. For a risk (a proportion p̂), the raw-data SD is √(p̂(1−p̂)), so:
SE(p̂) = √( p̂(1−p̂) / n )
More data → smaller SE → a tighter, more trustworthy estimate. That single relationship is why "n = 30" studies are shaky and "n = 30,000" studies are not.
3.6 The confidence interval — and what it does NOT mean
A point estimate alone hides its own uncertainty. Wrap it in an interval:
95% CI = estimate ± 1.96 · SE
Here is the sentence that separates people who get statistics from people who don't:
A 95% confidence interval does not mean "there is a 95% probability the true value is inside this interval." The true value is fixed; it is either in or out. What is random is the interval — it moves every time you resample. "95% confidence" is a property of the procedure: if you repeated the whole study many times, about 95% of the intervals you built would cover the true value. This one interval is just one of those tries.
The Monte-Carlo demo in §5 makes this concrete: we generate the true value ourselves, build thousands of intervals, and literally count that ~95% of them catch it.
3.7 The p-value in one paragraph
A p-value is the probability of seeing data at least as extreme as yours if there were truly no effect (the null hypothesis). Small p (say < 0.05) means "data this surprising would be rare under 'no effect,' so 'no effect' looks doubtful." It is emphatically not the probability that the null is true, nor the probability your result happened by chance. A confidence interval carries the same information more honestly: if a 95% CI for a difference excludes 0 (or a ratio excludes 1), the two-sided p-value is below 0.05.
4. The math
Core definitions (plain notation):
probability / risk : p = (number of events) / (total in the group)
odds from p : odds = p / (1 - p)
p from odds : p = odds / (1 + odds)
random variable X:
mean mu = (1/n) * sum(x_i)
variance var = (1/n) * sum( (x_i - mu)^2 )
std dev sd = sqrt(var)
Bernoulli(p): mean = p, variance = p*(1-p)
sampling:
SE = sd / sqrt(n)
SE of a risk = sqrt( p_hat * (1 - p_hat) / n )
95% confidence interval:
estimate +/- 1.96 * SE (1.96 leaves 2.5% in each normal tail)
Worked example 1 — mean, variance, SD of a small dataset. Data = [2, 4, 4, 4, 5, 5, 7, 9], n = 8.
mean mu = (2+4+4+4+5+5+7+9)/8 = 40/8 = 5
deviations (x - 5): -3, -1, -1, -1, 0, 0, 2, 4
squared: 9, 1, 1, 1, 0, 0, 4, 16 -> sum = 32
variance = 32/8 = 4
sd = sqrt(4) = 2
Worked example 2 — odds <-> probability round trip.
p = 0.15 -> odds = 0.15 / (1 - 0.15) = 0.15 / 0.85 = 0.1765
odds = 0.1765 -> p = 0.1765 / (1 + 0.1765) = 0.1765 / 1.1765 = 0.15 (back home)
fair coin: p = 0.5 -> odds = 0.5 / 0.5 = 1 ("even odds")
Worked example 3 — estimate a risk, get its SE and 95% CI. You watch n = 100 days and see 15 rainy days.
p_hat = 15 / 100 = 0.15
SE = sqrt( 0.15 * 0.85 / 100 ) = sqrt( 0.1275 / 100 ) = sqrt(0.001275) = 0.0357
95% CI = 0.15 +/- 1.96 * 0.0357 = 0.15 +/- 0.070 = (0.080, 0.220)
Report: risk = 15% (95% CI 8.0% to 22.0%)
Read it as: "our best guess is 15%, and the honest range consistent with this sample runs from about 8% to 22%." The interval is wide because 100 days is not much data.
Worked example 4 — the SE shrinks as √n. Same true p = 0.15, bigger samples:
n = 100 : SE = sqrt(0.1275/100) = 0.0357 half-width = 0.070
n = 400 : SE = sqrt(0.1275/400) = 0.0179 half-width = 0.035 (n x4 -> SE /2)
n = 1600 : SE = sqrt(0.1275/1600) = 0.00893 half-width = 0.018 (n x16 -> SE /4)
Quadruple the data and the error halves — the √n law in action. This is exactly why the confidence interval narrows when you collect more data.
5. Real code
Pure numpy, no special libraries and no API key. It estimates a risk from a sample, computes the SE and 95% CI, then runs a Monte-Carlo experiment: it invents the true value, repeats the sampling thousands of times, and counts how often the interval it builds actually covers the truth (it lands near 95%). It also shows the SE shrinking with n and the odds↔probability conversion.
"""Probability & statistics foundations, from scratch with numpy.
Shows: odds<->prob conversion, SE and 95% CI for a risk, a Monte-Carlo proof
that ~95% of 95% CIs cover the truth, and the SE shrinking as 1/sqrt(n)."""
import numpy as np
rng = np.random.default_rng(0) # seed so the numbers are reproducible
Z = 1.959964 # normal cutoff leaving 2.5% in each tail ("1.96")
# ---- odds <-> probability (two currencies for one chance) ----
def prob_to_odds(p): return p / (1 - p)
def odds_to_prob(o): return o / (1 + o)
p = 0.15
print("odds<->prob:")
print(f" p=0.15 -> odds = {prob_to_odds(p):.4f}") # 0.1765
print(f" odds=0.1765 -> p = {odds_to_prob(prob_to_odds(p)):.4f}") # back to 0.15
print(f" fair coin p=0.5 -> odds = {prob_to_odds(0.5):.1f}") # 1.0
# ---- estimate a risk from ONE sample, with SE and 95% CI ----
def risk_ci(events, n, z=Z):
p_hat = events / n
se = np.sqrt(p_hat * (1 - p_hat) / n) # SE of a proportion
return p_hat, se, (p_hat - z*se, p_hat + z*se)
p_hat, se, (lo, hi) = risk_ci(events=15, n=100)
print(f"\none sample (15 of 100): risk={p_hat:.3f} SE={se:.4f} "
f"95% CI ({lo:.3f}, {hi:.3f})")
# ---- Monte-Carlo: do ~95% of the 95% CIs cover the TRUE value? ----
TRUE_P, N, TRIALS = 0.15, 100, 20000
covered = 0
for _ in range(TRIALS):
events = rng.binomial(N, TRUE_P) # simulate one fresh sample
_, _, (lo, hi) = risk_ci(events, N)
if lo <= TRUE_P <= hi: # did THIS interval catch the truth?
covered += 1
print(f"\nMonte-Carlo coverage over {TRIALS} trials: "
f"{100*covered/TRIALS:.1f}% (target 95%)")
# ---- SE shrinks as 1/sqrt(n): quadruple n -> halve the SE ----
print("\nSE shrinks with n (true p=0.15):")
for n in (100, 400, 1600):
se_n = np.sqrt(TRUE_P * (1 - TRUE_P) / n)
print(f" n={n:5d} SE={se_n:.5f}")
Expected output (seed fixed, so it reproduces exactly):
odds<->prob:
p=0.15 -> odds = 0.1765
odds=0.1765 -> p = 0.1500
fair coin p=0.5 -> odds = 1.0
one sample (15 of 100): risk=0.150 SE=0.0357 95% CI (0.080, 0.220)
Monte-Carlo coverage over 20000 trials: 93.2% (target 95%)
SE shrinks with n (true p=0.15):
n= 100 SE=0.03571
n= 400 SE=0.01785
n= 1600 SE=0.00893
The Monte-Carlo line is the whole point: 93.2% ≈ 95% confirms what a confidence interval really promises — the procedure covers the truth about 95% of the time. It lands a touch under 95% because the simple normal (Wald) formula is only approximate for a proportion; with larger n, or a Wilson/exact interval, it tightens toward 95%.
6. Real-world example
An A/B test on a checkout button. You ship a new "Buy now" button to a random slice of traffic and want to know its true click-through risk.
- The sample. Of
n = 400visitors who saw the new button,72clicked. The estimated risk isp̂ = 72/400 = 0.18(18%). - The wobble.
SE = √(0.18·0.82/400) = √(0.1476/400) = 0.0192. The 95% CI is0.18 ± 1.96·0.0192 = 0.18 ± 0.0377 = (0.142, 0.218)— "somewhere between about 14% and 22%." - In odds. A product manager who thinks in odds hears
0.18/0.82 = 0.22— "roughly one click for every 4.5 non-clicks." - Do we have enough data? The interval is ±3.8 points, too loose to call a small win. To halve it to ±1.9 points you need four times the traffic —
n ≈ 1600— because SE falls as√n, notn. That single fact sets the length of the experiment. - Comparing to the old button. If the old button clicked at a known 15% and the new interval
(0.142, 0.218)still includes 15%, you cannot yet claim the new button is better — the data are consistent with "no real difference," and a p-value here would sit above 0.05. - The honest report. "New button: 18% CTR (95% CI 14.2%–22.0%), not yet distinguishable from the 15% baseline; extend the test to ~1600 users per arm to resolve it." That one sentence — estimate, interval, and what it would take to be sure — is the entire discipline in miniature.
These same proportions, once you have a treatment arm and a control arm side by side, are exactly what feed the 2×2 tables and effect measures in the evidence-synthesis track.
7. Interview questions companies actually ask
Q [Google / analytics] "What is the difference between probability and odds, and how do you
convert between them?"
A Probability (a risk) is events divided by EVERYONE: p = events/total, ranging 0 to 1. Odds is
events divided by NON-events: odds = p/(1-p), ranging 0 to infinity. Convert back with
p = odds/(1+odds). Example: p=0.15 -> odds 0.15/0.85 = 0.18. They are nearly equal when the
event is rare and diverge when it is common (a coin: p=0.5 but odds=1). Logistic regression
predicts log-odds precisely because odds are unbounded and symmetric.
Q [Amazon / data science] "Where does the number 1.96 come from in a 95% confidence interval?"
A It is the cutoff on the standard normal curve that leaves 2.5% of the area in each tail, so 95%
sits in the middle. Its exact value is 1.959964. For 99% you use 2.58 (0.5% per tail); for 90%
you use 1.645. There is nothing special about 1.96 except the 95% convention we chose.
Q [Meta / experimentation] "Explain what a 95% confidence interval actually means."
A It means the PROCEDURE covers the true value about 95% of the time: if you repeated the study
many times, about 95% of the intervals you build would contain the truth. It does NOT mean there
is a 95% probability the truth is in THIS particular interval — the truth is fixed; the interval
is what's random. You can prove it by simulation: generate a known true value, build thousands
of CIs, and ~95% of them cover it.
Q [Netflix / A-B testing] "Your standard error is too big. A colleague says 'just double the
sample.' What actually happens?"
A SE = SD/sqrt(n), so SE falls with the SQUARE ROOT of n. Doubling n multiplies SE by
1/sqrt(2) ~= 0.71 — only a 29% reduction, not half. To HALVE the SE you need 4x the data; to cut
it to a tenth you need 100x. This diminishing return is why big precision gains get expensive.
Q [a fintech] "What is a standard error and how is it different from a standard deviation?"
A Standard deviation describes the spread of the raw data points. Standard error describes the
spread of an ESTIMATE (like a sample mean or proportion) across hypothetical repeated samples:
SE = SD/sqrt(n). SD stays roughly constant as you collect more data; SE shrinks. A CI is built
from SE, not SD, because we're quantifying uncertainty in the estimate, not the data.
Q [a healthcare startup] "Define a p-value without saying 'chance' incorrectly."
A A p-value is the probability of observing data at least as extreme as what you saw, ASSUMING the
null hypothesis (no effect) is true. Small p means the data would be surprising under 'no
effect,' casting doubt on it. It is NOT the probability the null is true, and NOT the probability
your result was 'due to chance.' If a 95% CI for a difference excludes 0, the two-sided p < 0.05.
Q [Microsoft] "For a coin-flip-like event with probability p, what are the mean and variance of a
single trial?"
A A single Bernoulli trial (1 with probability p, else 0) has mean = p and variance = p(1-p).
Variance is largest at p=0.5 (0.25) and shrinks toward 0 as p approaches 0 or 1 — extreme
events are more predictable. The SD of an estimated proportion over n trials is
sqrt(p(1-p)/n), which is the SE we plug into the CI.
Q [a research lab] "Why does the normal distribution show up so often for averages and
proportions?"
A Because of the Central Limit Theorem: the sum or average of many independent, similarly-sized
random pieces tends toward a normal shape regardless of the original distribution. A proportion
is an average of 0/1 outcomes, so for reasonable n it is approximately normal — which is what
licenses the estimate +/- 1.96*SE interval in the first place.
Q [a consultancy] "You report a risk of 15% with no interval. What's missing and why does it
matter?"
A The uncertainty. 15% from 20 people (CI roughly 3%-38%) and 15% from 20,000 people (CI roughly
14.5%-15.5%) are wildly different claims but the same point estimate. Always report the estimate
WITH its confidence interval; a lonely number hides whether it's a firm finding or noise.
8. When to use / tradeoffs
REACH FOR EACH TOOL WHEN:
✓ risk / proportion — you want "how often out of everyone" (rates, CTR, event risk)
✓ odds — comparing to a baseline, or feeding logistic regression / log-odds
✓ mean + SD — summarizing a numeric variable's center and spread
✓ standard error — you're describing how much an ESTIMATE could wobble
✓ confidence interval— reporting any estimate honestly (estimate +/- 1.96*SE)
✓ p-value — a yes/no significance screen, ALWAYS paired with a CI / effect size
HONEST LIMITS:
✗ the normal +/-1.96*SE CI is an APPROXIMATION — it frays for tiny n or p near 0 or 1
(use exact/Wilson intervals or the bootstrap there)
✗ SE = SD/sqrt(n) assumes independent observations — clustered/correlated data need more care
✗ a p-value is not an effect size; "significant" can still be trivially small
✗ "95% CI" is about the procedure, never a probability statement about one fixed interval
THE REPORTING RULE:
never ship a point estimate alone — give the estimate AND its interval, and state n.
Probability turns counts into a number between 0 and 1; the standard error says how much that number could have wobbled; the confidence interval turns that wobble into an honest range. Get these three right and every downstream method — regression, A/B testing, meta-analysis — is just a more elaborate version of the same story.
9. Summary + related articles
- A probability is a proportion in [0, 1]; a risk is events divided by everyone in the group.
- Odds is the other currency — events per non-event — with
odds = p/(1−p)andp = odds/(1+odds); they agree when events are rare and diverge when common. - A random variable has a mean (center), variance (average squared spread), and SD = √variance (spread in original units); a Bernoulli event has mean
p, variancep(1−p). - The normal curve puts ≈68% within ±1 SD and ≈95% within ±1.96 SD; 1.96 is simply the cutoff leaving 2.5% in each tail.
- A sample estimate wobbles by the standard error
SE = SD/√n, which shrinks with √n — quadruple the data to halve the error. - A 95% confidence interval is
estimate ± 1.96·SE, and it means the procedure covers the truth ~95% of the time — not that this one interval has a 95% probability of holding it. - A p-value is the probability of data this extreme if there were no effect; report estimates with intervals, never alone.
Related: Logarithms, Exponents & the Log Scale · Weighted Averages & Aggregation · 2×2 Tables & Effect Measures (OR, RR, RD, NNT, HR)
Resources
- Blitzstein & Hwang, Introduction to Probability — clear treatment of random variables and the normal curve — https://projects.iq.harvard.edu/stat110/home
- Allen Downey, Think Stats — sampling, standard error, and confidence intervals in Python — https://greenteapress.com/wp/think-stats-2e/
- Cumming, "The New Statistics: Why and How" — what confidence intervals do and don't mean — https://journals.sagepub.com/doi/10.1177/0956797613504966
- Greenland et al., "Statistical tests, P values, confidence intervals, and power: a guide to misinterpretations" — https://link.springer.com/article/10.1007/s10654-016-0149-3
- Khan Academy, Statistics & Probability — https://www.khanacademy.org/math/statistics-probability