Discord

2Foundational Skills 2.3Mathematics Basics

2.3.2 Probability and Statistics

Understand uncertainty, summarise data, update beliefs with evidence, and avoid confusing correlation with causation.

Why probability and statistics matter

Machine learning is built from data, and data is rarely complete or perfectly predictable. A model does not simply say what will happen; it learns patterns from observations and often estimates what is likely to happen.

Probability gives us a language for uncertainty. It lets us describe possible outcomes, combine uncertain events and update a belief when new evidence arrives.

Statistics helps us understand observed data. It lets us summarise a dataset, compare groups, measure relationships and judge whether a pattern is meaningful or merely noise.

Together, they appear throughout AI:

  • A classifier may return a probability for each possible class.
  • A training set is a sample from a larger population we care about.
  • Evaluation metrics are statistics calculated from model predictions.
  • Bayes' theorem connects prior knowledge with new evidence.
  • Means, variances and percentiles help us inspect data before modelling.
  • Correlation can reveal a useful relationship, but it cannot by itself prove cause and effect.

Learn from these first

Use these two resources in order. You do not need to complete every advanced statistics unit before continuing with AI.

1. Khan Academy: Statistics and probability

Start with Khan Academy's Statistics and probability course. It combines short videos with practice questions and gives the gentlest introduction to the vocabulary on this page.

Focus on the parts covering:

  • summarising quantitative data;
  • mean, median, variance and percentiles;
  • probability and compound events;
  • independent, dependent and conditional events; and
  • relationships between two numerical variables.

2. Dive into Deep Learning: Probability and Statistics

Then read Dive into Deep Learning: Probability and Statistics. It connects the same ideas directly to machine learning and includes executable notebooks for several deep-learning frameworks.

Pay particular attention to:

  • probabilities as a description of uncertainty;
  • random variables and distributions;
  • conditional probability and independence;
  • Bayes' theorem; and
  • the distinction between a probability and a statistic calculated from data.

The connection between the topics

Topic Main question Connection to AI
Probability What outcomes are possible, and how likely are they? Models often estimate the probability of an output.
Conditional probability How does knowing one fact change another probability? Predictions depend on the features supplied to a model.
Independence Does knowing one event tell us anything about another? Independence assumptions can simplify a model; dependencies are often the patterns it must learn.
Bayes' theorem How should a belief change after seeing evidence? It connects prior knowledge, observed data and an updated prediction.
Descriptive statistics What does this dataset look like? Summaries reveal scale, spread, imbalance and unusual values before training.
Variables Which quantities are inputs, and which one is the outcome? Features are used to predict a target.
Correlation Do two quantities tend to vary together? Correlated features may be informative, redundant or driven by another factor.
Causation Does changing one quantity produce a change in another? Prediction alone does not establish what intervention will work.

Probability basics

A random experiment is a process whose exact result is uncertain. An outcome is one possible result, the sample space is the set of all possible outcomes, and an event is a collection of outcomes we care about.

A probability lies between 00 and 11:

  • P(A)=0P(A)=0 means event AA is impossible under the model.
  • P(A)=1P(A)=1 means event AA is certain under the model.
  • A larger value of P(A)P(A) means that AA is considered more likely.

The complement AcA^c means that AA does not occur, so

P(Ac)=1−P(A).P(A^c)=1-P(A).

The union A∪BA\cup B means that AA, BB or both occur. The intersection A∩BA\cap B means that both occur.

Conditional probability

The conditional probability P(A∣B)P(A\mid B) is the probability of AA after learning that BB has occurred:

P(A∣B)=P(A∩B)P(B),P(B)>0.P(A\mid B)=\frac{P(A\cap B)}{P(B)}, \qquad P(B)>0.

The condition changes the group being considered. This is the mathematical form of asking, “Among cases where BB is true, how often is AA also true?”

Independent and dependent events

Events AA and BB are independent when learning that one occurred does not change the probability of the other:

P(A∣B)=P(A).P(A\mid B)=P(A).

For independent events,

P(A∩B)=P(A)P(B).P(A\cap B)=P(A)P(B).

Events are dependent when knowing one event changes the probability of the other. In AI, dependencies are often useful signals: if an image feature changes the probability of a class, a model may be able to learn from that relationship.

Bayes' theorem

Bayes' theorem reverses a conditional probability:

P(A∣B)=P(B∣A)P(A)P(B).P(A\mid B)=\frac{P(B\mid A)P(A)}{P(B)}.

Its parts are often described as:

Part Meaning
P(A)P(A) The prior belief about AA before seeing the evidence.
P(B∣A)P(B\mid A) The likelihood of seeing evidence BB if AA is true.
P(B)P(B) The overall probability of seeing the evidence.
P(A∣B)P(A\mid B) The posterior belief about AA after seeing the evidence.

Bayes' theorem matters because the probability we want is often the reverse of the probability we can measure directly.

Practical applications

  • Medical testing: a test's accuracy is not the same as the probability that a person has the condition after a positive result; the condition's prevalence also matters.
  • Spam filtering: the words in a message act as evidence that updates the probability that the message is spam.
  • Classification: observed features can update the probability assigned to each possible class.
  • Fault detection: a sensor reading can update the probability that a machine or system has failed.

Descriptive statistics

Descriptive statistics reduce a dataset to a few values that reveal its centre, spread and position. They are usually the first things to inspect before choosing or training a model.

Measures of centre

Statistic Meaning What to remember
Mean The sum of the values divided by their count. Uses every value and can be pulled strongly by outliers.
Median The middle value after sorting. Often gives a better centre for skewed data or data with outliers.
Mode The most frequent value or category. Useful for categorical data and may not be unique.

The mean and median answer different questions, so neither is automatically the “correct” average.

Measures of spread and position

Statistic Meaning What to remember
Variance The average squared distance from the mean. Larger variance means the values are more spread out.
Standard deviation The square root of the variance. Describes spread in the same units as the original values.
Percentile A value at or below which a given percentage of observations falls. Useful for ranking a value relative to the rest of the data.

The $50$th percentile is the median. Percentiles are especially useful when a distribution is skewed or when a few extreme values make the mean misleading.

Variables in a dataset

A variable is a quantity or category recorded for each observation. In a supervised-learning table, variables usually play one of two roles:

Role Other common names Meaning in AI
Independent variable Predictor, explanatory variable, input, feature Information supplied to the model.
Dependent variable Response, outcome, target, label The value the model is intended to predict.

The terms describe a modelling role, not a guarantee of causation. Calling a column an independent variable does not prove that changing it would change the target.

Correlation and causation

Correlation means that two variables tend to vary together. A positive correlation means they tend to move in the same direction; a negative correlation means they tend to move in opposite directions.

A correlation coefficient is commonly between −1-1 and 11:

  • values near 11 indicate a strong positive linear relationship;
  • values near −1-1 indicate a strong negative linear relationship; and
  • values near 00 indicate little linear relationship.

A value near 00 does not rule out a curved or otherwise non-linear relationship.

Causation means that changing one variable produces a change in another. Correlation alone cannot establish this because the relationship may be explained by:

  • a confounding variable that influences both quantities;
  • reverse causality, where the assumed outcome actually influences the assumed cause;
  • selection or measurement bias; or
  • coincidence in a small or noisy dataset.

Controlled experiments, careful study design and causal assumptions are needed to support a causal claim. A predictive model can be highly accurate while learning correlations that are not causal.

How the ideas fit into an AI workflow

  1. Describe the data. Use counts, means, medians, variances and percentiles to understand each variable.
  2. Inspect relationships. Look for correlations and dependencies that might help prediction or reveal leakage and redundancy.
  3. Separate inputs from targets. Decide which variables are features and which outcome the model should predict.
  4. Represent uncertainty. Use probabilities rather than pretending every prediction is certain.
  5. Update with evidence. Use conditional probability and Bayes' theorem to understand how observations change a belief.
  6. Interpret carefully. Treat statistical association as evidence of a relationship, not automatic proof of causation.

What you should know before moving on

You should be able to:

  • explain the difference between probability and statistics;
  • recognise independent, dependent and conditional events;
  • describe what Bayes' theorem does and why the prior matters;
  • choose between mean, median and mode as a summary of centre;
  • explain variance, standard deviation and percentiles;
  • identify independent and dependent variables in a supervised-learning problem; and
  • explain why correlation does not by itself prove causation.

This foundation is enough for the first classical machine-learning modules. Later topics will add probability distributions, sampling, inference and model-specific uses of these ideas when they are needed.

Resources

SourceTitleWhy read it
Khan AcademyStatistics and probabilityStart here for short videos, explanations and practice on descriptive statistics, probability and relationships between variables.
Dive into Deep LearningProbability and StatisticsRead this next to see probability, conditional probability, Bayes' theorem and statistics connected directly to machine learning.

Finished this module? Mark it done.

Comments

Stuck on something, spotted a mistake, or found a resource that helped you? Tell us below.

Loading comments