Roll dice thousands of times and watch the messy experimental frequencies settle onto the exact theoretical answer. Probability is what happens in the long run — not what happens next.
Controls
The chart compares the experimental frequency with the theoretical probability as trials accumulate.
Experimental Frequency vs Theory
law of large numbers
Live Calculation
P(A)
0
P(B)
0
P(A and B)
0
P(A or B)
0
Sample space — every equally likely outcome
Probability Basics
Counting outcomes, combining events, and why a fair coin owes you nothing.
What this is
Probability measures how likely something is, on a scale from 0 (impossible) to 1 (certain). When every outcome is equally likely it is pure counting:
Sample Space and Events
The sample space is the complete list of things that could happen — the tiles shown under the chart. An event is any subset of it: "even number", "greater than 4". Selecting events A and B highlights their tiles, and tiles in both are the intersection.
Getting the sample space right is most of the work. For two dice there are 36 equally likely outcomes but only 11 possible sums — and those sums are not equally likely, which is why the two-dice chart is a triangle rather than a flat line.
Combining Events
That subtraction is the part people forget. Adding P(A) and P(B) double-counts every outcome living in both events, so you remove one copy. Pick two overlapping events and check the arithmetic against the live numbers.
When events cannot happen together — mutually exclusive — the overlap is 0 and the rule simplifies to plain addition.
Independence
Two events are independent when knowing one happened tells you nothing about the other. The test is arithmetic:
The app checks this for your chosen events and reports the verdict. It is a genuinely surprising result on a single die: "even" and "greater than 3" are not independent, while "even" and "greater than 4" happen to be — independence is a property of the numbers, not of intuition.
The Law of Large Numbers — and the Gambler's Fallacy
Press Run continuously. Early on the experimental line jumps around wildly; after a few thousand trials it settles onto the theoretical value and stays there.
That is the law of large numbers: averages converge in the long run. What it emphatically does not say is that outcomes "balance out". After ten heads, the next flip is still exactly 50/50 — the coin has no memory. Convergence happens because early flukes are diluted by the growing pile of trials, not because anything corrects them.
Counting what can happen
A probability is a number between 0 and 1 saying how likely an outcome is. Zero means impossible, one means certain, and everything interesting lives in between.
For situations where every outcome is equally likely, it is a counting exercise:
P(event) = favourable outcomes / total outcomes
A fair die: P(rolling a 4) = 1/6 ≈ 0.167. P(rolling an even number) = 3/6 = 0.5.
Three rules follow immediately and cover most of what you need:
Complement. P(not A) = 1 − P(A). Frequently the easy way round — "at least one" problems are almost always solved as 1 − P(none).
Addition. P(A or B) = P(A) + P(B) − P(A and B). The subtraction stops the overlap being counted twice.
Multiplication. P(A and B) = P(A) × P(B|A). When the events are independent, P(B|A) is just P(B).
Worked example: two dice, what is P(at least one six)? Directly it is fiddly. Via the complement: P(no six) = (5/6)×(5/6) = 25/36, so the answer is 1 − 25/36 = 11/36 ≈ 0.306.
Independence, and why it is usually assumed
Two events are independent when knowing one tells you nothing about the other. Coin flips are independent; drawing cards without replacement is not.
Independence matters because it makes the multiplication rule simple — multiply the probabilities and stop. Without it you need conditional probabilities for every combination, and the number of those grows exponentially.
This is exactly the trade Naive Bayes makes: assume every feature is independent given the class, so a joint probability over 20,000 words becomes a product of 20,000 easy numbers. The assumption is false and the classifier works anyway, because the errors it causes affect the magnitudes more than the ranking.
Checking independence is a real modelling step, not a formality. Repeated measurements on the same patient, sensor readings a second apart, and words in the same sentence are all correlated, and treating them as independent produces overconfident models.
Distributions in one page
A distribution describes the probabilities of every possible outcome at once.
Distribution
Models
Example
Bernoulli
One yes/no trial
A single coin flip
Binomial
Successes in n trials
Heads in 10 flips
Poisson
Events in a fixed interval
Support tickets per hour
Uniform
All outcomes equally likely
A fair die
Normal
Values clustered around a mean
Heights, measurement error
Exponential
Time until the next event
Time between arrivals
Two properties summarise most of them: the mean (where the centre is) and the variance (how spread out it is).
Discrete distributions assign probability to individual values; continuous ones assign probability to ranges, which is why the probability of any exact value is zero for a continuous variable. P(height = 180.000...) is zero; P(179.5 < height < 180.5) is not.
Roll it 600,000 times
Probability as a long-run frequency, measured rather than asserted.
example_01.pyNumPy
import numpy as np
rng = np.random.default_rng(0)
rolls = rng.integers(1, 7, size=600_000)
print("a fair die, 600,000 rolls:")
for face in range(1, 7):
print(" %d appeared %6.4f of the time" % (face, (rolls == face).mean()))
print()
two = rng.integers(1, 7, size=(600_000, 2)).sum(axis=1)
print("two dice, P(total = 7) measured %.4f, exact 6/36 = %.4f"
% ((two == 7).mean(), 6 / 36))
print(" P(total = 2) measured %.4f, exact 1/36 = %.4f"
% ((two == 2).mean(), 1 / 36))
print()
print("probabilities of all outcomes sum to 1:",
round(sum((two == t).mean() for t in range(2, 13)), 6))
Output
Things to try
Roll 1 a few times. Individual results look nothing like the theory — probability says nothing about single trials.
Now run continuously and watch the gap between the bars and the theoretical markers close.
Reset and note the error at 10, 100 and 10,000 trials. It shrinks roughly with √n — four times the data halves the error.
Switch to two dice. The distribution becomes a triangle peaking at 7, because 7 has six ways to occur while 12 has only one.
Try event pairs and watch the independence verdict flip between "independent" and "dependent".
Summing up
Count the outcomes, define events as subsets, subtract the overlap when combining with OR, and multiply only when events are genuinely independent. Probability describes long-run behaviour — it makes no promise whatsoever about your next roll.
Expected value: the number decisions are made on
The expected value is the long-run average outcome — each value weighted by its probability.
E[X] = Σ x × P(x)
A fair die: (1+2+3+4+5+6)/6 = 3.5. Note that 3.5 is not a possible roll; an expected value is an average, not a prediction.
The reason it matters is that it turns a set of uncertain outcomes into a single comparable number:
A model flags 1,000 transactions. Each flag costs £5 to review, and each fraud caught saves £200. At a 12% precision, the expected value is 1,000 × (0.12×200 − 5) = 1,000 × 19 = £19,000. Raise the threshold to reach 30% precision but only 400 flags: 400 × (0.3×200 − 5) = £22,000. The second is better, and no accuracy metric would have told you that.
Every threshold decision, every "should we ship this model", and every A/B test readout is an expected-value calculation underneath.
Common misconceptions
The gambler's fallacy. Five heads in a row does not make tails more likely next. Independent events have no memory.
Confusing P(A|B) with P(B|A). The probability of a positive test given the disease is not the probability of the disease given a positive test. These differ enormously for rare conditions, and Bayes' theorem is what converts between them.
Ignoring the base rate. A 99%-accurate test for a 1-in-10,000 condition produces about 100 false positives for every true one.
Reading small samples as signal. Three conversions from ten visitors is not a 30% conversion rate; the confidence interval spans most of the range.
Assuming independence where measurements are repeated on the same subject.
Questions people ask
What is the difference between probability and statistics? Probability reasons from a known model to expected data; statistics reasons from observed data back to a plausible model.
Can a probability be greater than 1? No. A probability density can exceed 1, because it is a density over a range rather than a probability of a point — the area under it still totals 1.
What are odds? The ratio of "happens" to "does not": a probability of 0.75 is odds of 3 to 1. Logistic regression works in log-odds because they are unbounded and additive.
How many samples do I need? It depends on the effect you want to detect. A power calculation gives the number; guessing gives an inconclusive experiment.
Why is the normal distribution everywhere? The central limit theorem: sums and averages of many independent contributions tend towards a normal shape, whatever the individual distributions look like.
Is a p-value the probability that my hypothesis is wrong? No — it is the probability of seeing data this extreme if the null hypothesis were true. The two are routinely confused and are not the same thing.
Recap in one screen
Probability runs from 0 to 1; for equally likely outcomes it is a counting ratio.
Complement, addition and multiplication cover most calculations — and "at least one" is usually easiest via the complement.
Independence makes probabilities multiply, which is why models assume it even when it is not quite true.
A distribution describes all outcomes at once; mean and variance summarise it.
Expected value converts uncertainty into one number you can make a decision with.
Check yourself
0 of 3
Answer without scrolling back up.
Two fair coin flips. What is the probability of two heads?
Independent events multiply: 1/2 x 1/2 = 1/4. The four equally likely outcomes are HH, HT, TH, TT, and only one of them qualifies.
P(A|B) means:
The bar is 'given'. Conditioning narrows the world to the cases where B is true and asks how often A holds within that smaller set. Swapping the two sides gives a different number - assuming otherwise is the base-rate fallacy.
A test is 99% accurate for a disease affecting 1 in 10,000 people. You test positive. Roughly how worried should you be?
Among 10,000 people there is about 1 true case and about 100 false positives, so a positive result is right roughly 1 time in 100. The base rate dominates, which is exactly what Bayes' rule formalises.
Cheat sheet
Probability Basics
Roll dice thousands of times and watch the messy experimental frequencies settle onto the exact theoretical answer. Probability is what happens in the long run — not what happens next.
Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.