01 / 22 · Foundations
What probability is
Why the event, conditioning information and sampling mechanism matter. We connect probability with counting, frequencies and uncertainty, then work through selection, collisions, changing group weights and the limits of averaging.
On this page 4
An archive restoration takes more than ten seconds in 80% of cases. A task has taken more than ten seconds. Does that make it an archive restoration with probability 80%? The answer depends on what other tasks enter the queue and how often they also take that long. Before calculating a probability, we need to identify the event and the information already known.
The same distinction matters when a classifier flags an example or an experiment reports an improvement. A learning algorithm can be deterministic and output only a label. Probability still gives us a way to describe how its errors vary when the input sample changes. Some models also output probability distributions; their numbers need assumptions and empirical checks of their own.
Three readings of a probability#
Let be the set of possible outcomes. An event is a specified collection of outcomes; is the probability assigned to it. We use the usual probability rules in this course. Their interpretation is a separate question: are we describing a sampling mechanism, a repeated frequency, or uncertainty given information? These readings are useful starting points, rather than an exhaustive or universally agreed philosophical classification (Hájek, 2023, sections 1 and 3).
Counting under an equal-probability assumption. Suppose a generator chooses uniformly from eight distinct status codes and three codes require manual inspection. Each code then has probability , and the inspection event has probability . For a finite uniform model, counting gives
Here counts outcomes in the event. Uniformity is an assumption about the generator; merely not knowing its preferences does not establish it. With unequal code probabilities, we add the probabilities of the three selected codes instead. The counting topic develops the finite case; the axioms give a framework that also covers infinite spaces.
Frequencies across repetitions. After trials, let be 1 when trial requires inspection and 0 otherwise. The observed share is
This is a statistic of a finite sample. In an independent, identically distributed Bernoulli model with inspection probability , its expectation is . Since an indicator has variance and independent variances add, the variance and root mean squared error are
Variance measures squared spread across possible repetitions of the whole sample. The square root has the units of a proportion. Multiplying the sample size by four halves this root mean squared error. It does not require the error of one particular observed path to halve.
Frequency fluctuates around the specified probability
The weak law of large numbers says that the chance of a fixed nonzero deviation tends to zero under these assumptions. One route uses the fact that a nonnegative squared error exceeding contributes at least that much to its expectation. Therefore, for any fixed ,
This bound can exceed 1 for small samples, so it need not be numerically informative there. It describes a probability across samples, without a monotone guarantee for any one path. A stronger almost-sure statement is developed in the law of large numbers. The moment calculation and the weak-law argument are checked against Siegrist’s treatment.
Uncertainty given information. We can also assign a probability to a particular future task exceeding its deadline, conditional on what we know now. This does not require that exact task to recur. A Bayesian model specifies probabilities and updates them when evidence arrives. Coherence of those assignments is distinct from empirical calibration: forecasts near 0.7 are calibrated on a specified population when approximately 70% of those events occur. Arithmetic consistency alone cannot establish that agreement with observations. The interpretation and its assumptions need to be stated; we do not settle them by drawing three simulated paths.
Where intuition fails#
Selection changes the denominator. Return to the queue. Construct a finite population of 200 tasks and select one uniformly. There are three task classes. The following counts are specified teaching inputs, not measurements of a real service. A long task means one taking more than ten seconds.
| Task class | All tasks | Long tasks | Long share within class |
|---|---|---|---|
| Synchronization | 140 | 7 | 1/20 |
| Index rebuild | 40 | 10 | 1/4 |
| Archive restore | 20 | 16 | 4/5 |
| Total | 200 | 33 | 33/200 |
Let be archive restoration and be a long task. Before observing duration, . Among archive restorations, . Once we learn that the task is long, the possible rows are the 33 long tasks; 16 of them are archive restorations. By the definition of conditional probability,
The notation after the vertical bar names the information we condition on. Reversing it changes which rows make up the denominator. The general conditional-probability definition requires the conditioning event to have positive probability.
Change the job mix, keep the conditional rates
Now construct a second population with 80 synchronization tasks, 40 index rebuilds and 80 restorations. Preserve the same within-class long shares. The long counts become 4, 10 and 64. Thus
Both populations have the same 80% long rate among restorations. Their restoration shares among long tasks differ because the initial mix differs. This is where base rates, the probabilities before the new observation, enter the calculation. Bayes’ formula expresses the same selection using conditional rates and initial weights.
Any collision differs from one specified match. Suppose each new object receives an independent uniform six-bit identifier, so there are 64 possible values. This deliberately small model lets us see collisions early. For , the first identifier has no earlier value to avoid; the second must avoid one; the third must avoid two. Multiplying these conditional probabilities gives
The probabilities are 0.445226 for nine objects and 0.523241 for ten, rounded to six decimals. Ten is the first sample size at which the probability reaches one half. A pair chosen in advance matches with probability ; asking whether any pair matches is a different event. We multiplied conditional probabilities of avoiding earlier values, rather than treating all pairwise collision events as independent. For more than 64 objects a collision is certain. The general occupancy calculation is the familiar birthday-problem mechanism (Siegrist); these inputs are a separate small identifier model, with no claim about an actual hash implementation.
Different group weights reverse an aggregate. Consider another constructed table: two processing methods and whether a task meets its deadline. Class 1, 2 and 3 are three workload strata. Each entry is successful tasks divided by all tasks assigned to that method in that stratum.
| Workload stratum | Method A | Method B |
|---|---|---|
| Class 1 | 3/4 | 8/12 |
| Class 2 | 4/8 | 1/3 |
| Class 3 | 2/8 | 0/1 |
| Pooled | 9/20 | 9/16 |
A has the higher success share in every row, yet its pooled share is 0.45, below B’s 0.5625. A’s mix puts 8 of its 20 tasks into the lowest-success class; B puts only 1 of its 16 there. Each pooled rate uses its own weights. This reversal is called Simpson’s paradox.
For a new comparison, specify the same target mix for both methods: one third from each class. The standardized rates are
These answer a different descriptive question from the pooled rates. They do not prove that switching a task to A causes improvement. That would require assumptions about assignment, relevant confounders and how the strata relate to the intervention. Nor should we always condition on every available variable. Pearl’s analysis, sections 1–2, explains why a causal choice cannot be resolved from the reversal table alone. The small denominators here also give no reliable precision claim about a real population.
A shared error survives averaging. Let independent measurement errors equal either or , each with probability one half. Their mean is zero and variance is 4. For measurements , the average estimates a fixed quantity with variance and standard deviation .
Now add a shared random batch offset , equal to or with equal probability and independent of every . Every measurement in the same batch uses the same . Then
At , independent-error standard deviations are 1, 0.5 and 0.25. With the shared offset they are approximately 1.4142, 1.1180 and 1.0308. Across randomly drawn batches, the standard deviation approaches 1. Within a batch the offset remains fixed; averaging more measurements cannot identify or remove it. A fixed unknown bias is a related but different model: its squared magnitude contributes to mean squared error rather than to sampling variance. Joint distributions develop the covariance terms behind such limits.
What the course builds#
The calculations above use different tools because they ask different questions. Counting handles a specified finite uniform experiment. Conditioning selects a smaller population. Expectations and variances summarize random quantities; limit theorems relate repeated samples to their generating assumptions.
| Question | Next tools |
|---|---|
| Which outcomes count as the event? | Outcomes, events and counting |
| How do we assign probabilities beyond finite uniform spaces? | Kolmogorov’s axioms |
| How does new information change a probability? | Conditional probability and Bayes’ formula |
| How do we describe random numerical values? | Discrete and continuous distributions, transformations |
| How do we summarize spread and dependence? | Expectation, variance, joint distributions, conditional expectation |
| What does averaging guarantee? | Inequalities, laws of large numbers, the central limit theorem |
| How do observations inform unknown parameters? | Estimation, maximum likelihood, Bayesian inference |
| How uncertain is an estimate or comparison? | Confidence intervals, bootstrap, hypothesis tests |
| How do random states evolve and how can we sample? | Markov chains, Monte Carlo, MCMC |
Continuous distributions require integrals; multivariate Gaussian models also use matrix operations. Mathematics for Machine Learning develops that notation alongside this course.
The connection to learning depends on the model. Squared-error fitting corresponds to Gaussian negative log-likelihood when the conditional variance is fixed; other objectives need their own interpretation. A regularization penalty has a Bayesian prior interpretation only when the proposed density and normalizing conditions make sense. For evaluation, a fixed classifier’s average error on independent, representative held-out examples is a sample mean. Choosing a classifier after inspecting those same examples changes the argument: a pointwise law of large numbers alone does not justify adaptive model selection. The maximum-likelihood, Bayesian-inference and concentration topics state the relevant conditions.
What changed#
The task queue calculation becomes determined once we specify which rows are eligible. The method comparison becomes determined once we specify the workload weights. The averaging calculation becomes determined once we specify which errors are shared. An unexplained percentage leaves these choices hidden; a probability model makes them inspectable.
Limitations#
All numerical populations and measurement mechanisms here are constructed examples. No task timings, treatment outcomes or model scores were collected. Exact arithmetic verifies consequences of the specified inputs; it cannot establish that those inputs describe a real service.
The collision model assumes independent uniform identifiers. The frequency calculation assumes a fixed Bernoulli probability and independent repetitions. Drift, selection and shared errors can invalidate an application of those calculations. A probability distribution also does not by itself tell us the cost of a mistake or which intervention to choose.
What you should remember#
- State the event, the conditioning information and the sampling mechanism.
- Equal weights require an assumption; ignorance alone does not establish uniformity.
- A finite frequency estimates a model probability under stated sampling conditions.
- Reversing a conditional changes the denominator; initial group weights matter.
- Pooled and standardized rates answer different questions; neither alone establishes causality.
- Independent averaging reduces root mean squared error at a square-root rate; shared error can leave a floor.
Code#
This standard-library calculation reproduces the constructed counts, collision threshold, common-weight comparison and measurement spreads. The independent finite-state checks and figure-path replay are in the verification script. The examples were authored for this project with AI assistance; they use no external dataset.
from fractions import Fraction
from math import prod, sqrt
mixes = [(140, 40, 20), (80, 40, 80)]
rates = [Fraction(1, 20), Fraction(1, 4), Fraction(4, 5)]
for counts in mixes:
long_jobs = [n * rate for n, rate in zip(counts, rates)]
posterior = long_jobs[2] / sum(long_jobs)
print('long jobs:', [int(x) for x in long_jobs],
'archive share:', str(posterior))
def collision(n, labels=64):
if n > labels:
return Fraction(1)
return 1 - prod(Fraction(labels - i, labels) for i in range(n))
print('collision n=9,10:', *(f'{float(collision(n)):.6f}' for n in (9, 10)))
print('first n at least half:', next(n for n in range(1, 66) if collision(n) >= Fraction(1, 2)))
a = [(3, 4), (4, 8), (2, 8)]
b = [(8, 12), (1, 3), (0, 1)]
for label, groups in [('A', a), ('B', b)]:
pooled = Fraction(sum(x for x, _ in groups), sum(n for _, n in groups))
standardized = sum(Fraction(x, n) for x, n in groups) / 3
print(label, 'pooled:', str(pooled), 'equal mix:', str(standardized))
for n in (4, 16, 64):
print('n:', n, 'independent SD:', f'{2 / sqrt(n):.6f}',
'shared-offset SD:', f'{sqrt(1 + 4 / n):.6f}')
long jobs: [7, 10, 16] archive share: 16/33
long jobs: [4, 10, 64] archive share: 32/39
collision n=9,10: 0.445226 0.523241
first n at least half: 10
A pooled: 9/20 equal mix: 1/2
B pooled: 9/16 equal mix: 1/3
n: 4 independent SD: 1.000000 shared-offset SD: 1.414214
n: 16 independent SD: 0.500000 shared-offset SD: 1.118034
n: 64 independent SD: 0.250000 shared-offset SD: 1.030776
Next#
The identifier calculation multiplied the number of remaining choices. Outcomes, events and counting develops that step: define the sample space first, then count the outcomes belonging to the event.
References#
- Alan Hájek. Interpretations of Probability. Stanford Encyclopedia of Philosophy, substantive revision November 16, 2023. Sections 1, 3.1, 3.3 and 3.4: formal rules, equal-probability assumptions, credence and frequency interpretations. Factual reference; no source examples or prose reproduced.
- Kyle Siegrist. Probability, Mathematical Statistics, and Stochastic Processes: Conditional Probability, The Law of Large Numbers, and The Birthday Problem. Definitions, Moments/Weak and Strong Laws, and Simple Birthday Problem sections, accessed November 13, 2026. Author’s open educational text under CC BY 2.0; used to check general mathematics. The task populations, measurement fixture, code and figures above are newly specified for this project.
- Judea Pearl. Understanding Simpson’s Paradox. UCLA Technical Report R-414, December 2013; subsequently published in The American Statistician, 2014. Sections 1–2: association reversal and the need for causal assumptions. Factual reference; no source data or diagrams reused.