Course contents 01 / 22

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 Ω\Omega be the set of possible outcomes. An event AA is a specified collection of outcomes; P(A)P(A) 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 1/81/8, and the inspection event has probability 3/83/8. For a finite uniform model, counting gives

P(A)=∣A∣∣Ω∣.P(A)=\frac{|A|}{|\Omega|}.

Here ∣A∣|A| 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 nn trials, let IiI_i be 1 when trial ii requires inspection and 0 otherwise. The observed share is

p^n=1n∑i=1nIi.\widehat p_n=\frac{1}{n}\sum_{i=1}^{n}I_i.

This is a statistic of a finite sample. In an independent, identically distributed Bernoulli model with inspection probability pp, its expectation is pp. Since an indicator has variance p(1−p)p(1-p) and independent variances add, the variance and root mean squared error are

Var⁡(p^n)=p(1−p)n,E[(p^n−p)2]=p(1−p)n.\begin{aligned} \operatorname{Var}(\widehat p_n)&=\frac{p(1-p)}{n},\\ \sqrt{\mathbb E[(\widehat p_n-p)^2]}&=\sqrt{\frac{p(1-p)}{n}}. \end{aligned}

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.

Figure

Frequency fluctuates around the specified probability

Frequency fluctuates around the specified probabilityThree reproducible pseudorandom series with p=3/8 and 4096 trials each. Frequencies are shown from trial eight on a logarithmic horizontal axis. The dashed line marks the specified p. Finite paths illustrate fluctuations; they do not prove the law of large numbers or define a confidence band.00.37518645124096Number of trials nAt n=4096: 0.3711 / 0.3770 / 0.3777
Three reproducible pseudorandom series with p=3/8 and 4096 trials each. Frequencies are shown from trial eight on a logarithmic horizontal axis. The dashed line marks the specified p. Finite paths illustrate fluctuations; they do not prove the law of large numbers or define a confidence band.

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 ε2\varepsilon^2 contributes at least that much to its expectation. Therefore, for any fixed ε>0\varepsilon>0,

P(∣p^n−p∣≥ε)≤p(1−p)nε2⟶0.P(|\widehat p_n-p|\geq\varepsilon) \leq\frac{p(1-p)}{n\varepsilon^2} \longrightarrow 0.

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 classAll tasksLong tasksLong share within class
Synchronization14071/20
Index rebuild40101/4
Archive restore20164/5
Total2003333/200

Let RR be archive restoration and LL be a long task. Before observing duration, P(R)=20/200P(R)=20/200. Among archive restorations, P(L∣R)=16/20P(L\mid R)=16/20. 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,

P(R∣L)=P(R∩L)P(L)=16/20033/200=1633≈0.4848.\begin{aligned} P(R\mid L)&=\frac{P(R\cap L)}{P(L)}\\ &=\frac{16/200}{33/200}\\ &=\frac{16}{33}\approx0.4848. \end{aligned}

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.

Figure

Change the job mix, keep the conditional rates

Change the job mix, keep the conditional ratesEach panel is a specified population of 200 jobs. Bars show long jobs only, on the same scale. Keeping long-job rates within categories fixed changes the archive share among long jobs from 16/33 to 64/78. The selection condition and denominator matter.Mix 1: 140 / 40 / 20 jobsSynchronization7 / 140Index rebuild10 / 40Archive restore16 / 20Archive among long jobs: 16/33Mix 2: 80 / 40 / 80 jobsSynchronization4 / 80Index rebuild10 / 40Archive restore64 / 80Archive among long jobs: 64/78
Each panel is a specified population of 200 jobs. Bars show long jobs only, on the same scale. Keeping long-job rates within categories fixed changes the archive share among long jobs from 16/33 to 64/78. The selection condition and denominator matter.

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

P(R∣L)=644+10+64=3239≈0.8205.P(R\mid L)=\frac{64}{4+10+64}=\frac{32}{39}\approx0.8205.

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 n≤64n\leq64, the first identifier has no earlier value to avoid; the second must avoid one; the third must avoid two. Multiplying these conditional probabilities gives

P(all distinct)=∏i=0n−164−i64,P(at least one collision)=1−P(all distinct).\begin{aligned} P(\text{all distinct})&=\prod_{i=0}^{n-1}\frac{64-i}{64},\\ P(\text{at least one collision})&=1-P(\text{all distinct}). \end{aligned}

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 1/641/64; 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 stratumMethod AMethod B
Class 13/48/12
Class 24/81/3
Class 32/80/1
Pooled9/209/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

qA=13(34+48+28)=12,qB=13(812+13+01)=13.\begin{aligned} q_A&=\frac{1}{3}\left(\frac34+\frac48+\frac28\right)=\frac12,\\ q_B&=\frac{1}{3}\left(\frac8{12}+\frac13+\frac01\right)=\frac13. \end{aligned}

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 EiE_i equal either −2-2 or 22, each with probability one half. Their mean is zero and variance is 4. For measurements Xi=θ+EiX_i=\theta+E_i, the average estimates a fixed quantity θ\theta with variance 4/n4/n and standard deviation 2/n2/\sqrt n.

Now add a shared random batch offset CC, equal to −1-1 or 11 with equal probability and independent of every EiE_i. Every measurement in the same batch uses the same CC. Then

Xi=θ+C+Ei,X‾−θ=C+1n∑i=1nEi,Var⁡(X‾−θ)=1+4n.\begin{aligned} X_i&=\theta+C+E_i,\\ \overline X-\theta&=C+\frac{1}{n}\sum_{i=1}^{n}E_i,\\ \operatorname{Var}(\overline X-\theta)&=1+\frac4n. \end{aligned}

At n=4,16,64n=4,16,64, 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.

QuestionNext 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.