Probability & Statistics for AI
An AI system may output “80% likely,” but what would make that number meaningful? Begin with counts of possible and observed outcomes, ordinary fractions, and repeated coin-like trials. Learn how new evidence changes a probability, how a random quantity receives a distribution, and how averages from samples can vary. Estimation, uncertainty intervals, comparisons, and calibration are introduced through small tables before general formulas. Experiments and causal claims come last, with a strict boundary between prediction, association, and evidence that an intervention caused a change.
Probability models and sample spaces
Objective Define outcomes, events, and probability measures that match the question an AI system must answer.
Core explanation
Probability begins with a sample space of possible outcomes, events defined as subsets of those outcomes, and a probability measure that assigns consistent mass. The model is not the world; it is a deliberately simplified description of uncertainty for a specific question. A coin-flip space may be adequate for a randomized experiment but inadequate for sequential user behavior where outcomes depend on history. Mutually exclusive events cannot occur together, while exhaustive events cover every allowed outcome. Complements, unions, and intersections turn verbal requirements into calculations. Before estimating anything, define the observational unit, reference population, time horizon, and what counts as an outcome. Ambiguous sample spaces produce precise-looking but meaningless numbers, especially when logs contain repeated events from the same person.
Define the objects and assumptions in Probability models and sample spaces
A probability model defines a sample space of possible outcomes, a collection of events, and a measure assigning mass consistently. Mutually exclusive events cannot occur together; exhaustive events cover the space. Complements and unions obey derived rules, while probabilities do not describe anything until the unit, population, time, and observation process are named. For an explicit probability model for an AI service event, begin by naming the mathematical objects, their domains and codomains, the population or data source, and which equalities are definitions, derived results, approximations, or empirical claims. Translate every symbol into a sentence and every sentence back into a typed quantity so a beginner can check that the problem being solved is the problem that was asked.
Define the experimental or observational unit, repeated trial, outcome granularity, population, time horizon, censoring, missing events, and whether probabilities are frequencies, subjective beliefs, or calibrated predictions. A log row, user, request, session, and day are different sample spaces; changing the unit changes denominators and dependence. Create a notation and shape table before calculating. Include units, support, coordinate or basis choices, conditioning information, fitted state, and invalid inputs. Give one ordinary example, one boundary example, and one counterexample. This prevents syntactically legal arithmetic from silently answering a different question.
Derive and interpret the central result for Probability models and sample spaces
Derive complement and inclusion-exclusion rules from disjoint additivity, then enumerate a small finite space with equally and unequally likely outcomes. Build a probability tree for a multi-stage event and show how impossible, unobserved, and zero-probability outcomes differ. Write the derivation line by line, cite the definition or theorem used at each transition, and check dimensions, signs, normalization constants, and limiting behavior. A derivation is complete only when the learner can explain why each transformation is allowed and what the final expression says about the original problem.
Build two hand-checkable instances of an explicit probability model for an AI service event: one satisfying the premises and one changing exactly one premise. The chapter-specific interpretation is this: Define the experimental or observational unit, repeated trial, outcome granularity, population, time horizon, censoring, missing events, and whether probabilities are frequencies, subjective beliefs, or calibrated predictions. A log row, user, request, session, and day are different sample spaces; changing the unit changes denominators and dependence. Substitute small values, calculate intermediate quantities, and explain why the two outcomes differ before using software; the contrast separates mathematical necessity from representation, data, approximation, and product policy.
Compute and diagnose an explicit probability model for an AI service event
Enumerate exact probabilities for a tiny service workflow and verify them with simulation under a controlled generator. Test duplicate logging, dropped events, overlapping categories, variable exposure time, rare outcomes, truncated windows, changing populations, and probabilities that fail nonnegativity or normalization. Preserve the input fixture, code version, dtype, random generator state, fitted transformations, expected invariants, and a reference calculation. Inspect intermediate shapes and values instead of accepting a plausible final scalar. Complexity, memory, convergence, and numerical range belong to the algorithm contract just as much as the formula.
The diagnostic mutation is: The model fails when the denominator silently changes from users to requests, observed categories are assumed exhaustive, absence from logs is called impossibility, or repeated events from one user are treated as independent trials. Reproduce it with the smallest example, locate the first violated definition, assumption, shape, independence, numerical, or evaluation invariant, and repair that boundary. Re-run ordinary, boundary, adversarial, shifted, and repeated cases so the repair does not merely hide the final symptom.
Laboratory: build an explicit probability model for an AI service event
First write a one-page specification from these controls: A probability model defines a sample space of possible outcomes, a collection of events, and a measure assigning mass consistently. Mutually exclusive events cannot occur together; exhaustive events cover the space. Complements and unions obey derived rules, while probabilities do not describe anything until the unit, population, time, and observation process are named. Define the experimental or observational unit, repeated trial, outcome granularity, population, time horizon, censoring, missing events, and whether probabilities are frequencies, subjective beliefs, or calibrated predictions. A log row, user, request, session, and day are different sample spaces; changing the unit changes denominators and dependence. Then derive the expected result for a tiny fixture, implement the simplest transparent version, compare it with an independent calculation or trusted library, and visualize the geometry, distribution, optimization path, graph, or error curve that carries the chapter’s meaning. Record failures and uncertainty rather than deleting inconvenient trials.
Acceptance requires the learner to explain the derivation without the code, reproduce and repair “The model fails when the denominator silently changes from users to requests, observed categories are assumed exhaustive, absence from logs is called impossibility, or repeated events from one user are treated as independent trials.”, and then add a timeout outcome and revise the space, logging, denominators, and checks coherently. Deliver formulas with assumptions, annotated computations, tests and counterexamples, numerical and statistical tolerances, plots with labeled axes, exact environment and artifact identity, limitations, and a short teach-back that predicts an unseen case.