Explainer
Probability for machine learning: distributions, likelihood, Bayes
Probability theory is the mathematics of uncertainty, and machine learning always has to deal with uncertain quantities.[1][2] Classification models turn raw scores into a probability for each possible answer with a softmax function, and in generative models a temperature setting controls how random the output is.[3][4] Many models are trained by maximum likelihood, which amounts to minimising cross-entropy.[5]
This is the second step in our machine learning foundations series, after linear algebra for machine learning. Next comes how machine learning works, then loss functions, which builds directly on the last section here.
When a classifier rates an email as, say, 97% likely to be spam, it is reporting a probability: its softmax output turns raw scores into probabilities that add up to 1.[3] Probability theory is the study of uncertainty, a mathematical framework for representing uncertain statements.[1] The deep learning textbook by Goodfellow, Bengio and Courville points out that machine learning must always deal with uncertain quantities and sometimes random ones, which is why probability sits underneath almost every model.[2]
Two ways to read a probability
A probability can describe how often something happens, such as the share of coin flips that land heads. It can also describe how certain we are, such as a doctor’s confidence in a diagnosis. The first reading is called frequentist probability and the second Bayesian probability, and the textbook notes that the same formulas apply to both.[6] The wider debate between the two schools of statistics is covered in Bayesian vs frequentist statistics.
Distributions, averages and spread
A probability distribution lists how likely each possible outcome is. Two simple ones appear everywhere in machine learning. The Bernoulli distribution covers a single yes-or-no outcome, such as one coin flip, and is controlled by a single probability. The normal, or Gaussian, distribution is the familiar bell curve, the most common distribution over real numbers.[7]
The expected value is the average you would get if you drew from the distribution many times. The variance measures how spread out the values are around that average, and its square root is the standard deviation.[8]
A Bernoulli distribution is a distribution over a single binary random variable with one parameter, the probability of a 1. The normal or Gaussian distribution is the most commonly used distribution over real numbers.[7] The expectation of f(x) under P(x) is the mean value f takes when x is drawn from P, the variance measures how much f(x) varies around that mean, and the standard deviation is its square root.[8] See the normal distribution for more on the bell curve.
Conditional probability and Bayes’ rule
A conditional probability is the probability of one event given that another has happened, such as the chance of rain given dark clouds. Two events are independent when observing one does not change the probability of the other.[9]
Bayes’ rule handles a common problem: you know the probability of the evidence given a cause, P(y | x), but want the probability of the cause given the evidence, P(x | y). If you also know how common the cause is, P(x), the rule gives the answer.[10] It follows directly from the definition of conditional probability and is named after the Reverend Thomas Bayes, who discovered a special case of it.[10]
Some models carry this kind of uncertainty all the way to their outputs. Google’s glossary contrasts a standard network that predicts a house price of 853,000 with a Bayesian neural network that predicts 853,000 with a standard deviation of 67,200.[11]
How models output probabilities
A classifier first produces a raw score for each possible answer. A function called softmax turns those scores into probabilities that add up to exactly 1.[3] An image model might say: dog 85%, cat 13%, horse 2%.
Generative models such as chatbots then pick from those probabilities. A setting called temperature controls how adventurous that choice is: higher temperatures give more random output, lower temperatures more predictable output.[4]
The vector of raw, unnormalised predictions is called the logits, and softmax maps it to a probability for each class that sums to 1.0.[3] Temperature is a hyperparameter controlling the randomness of a generative model’s output, with higher values giving more random samples.[4] A masked language model predicts the probability of candidate tokens to fill a blank in a sequence.[12] Filling in hidden parts of the input like this is a form of self-supervised learning. See how large language models work.
Likelihood: how training uses probability
A model with probabilistic outputs assigns some probability to the right answers in its training data. Maximum likelihood training chooses the parameters that make those right answers as probable as possible. In practice that means minimising the negative log-likelihood, which is equivalent to minimising the cross-entropy.[5] Stanford’s CS231n notes describe the standard softmax classifier in exactly these terms: minimising the negative log likelihood of the correct class is maximum likelihood estimation.[5]
Loss functions explained picks up the story from here, with cross-entropy and the other measures of error that models minimise.
This page covers the probability needed for the rest of the series. It leaves out measure theory, continuous densities and most of statistics; for testing results, see p-values and statistical significance.
Read next
Next in the crash course
How machine learning works: data, models, training and testing
A plain guide to machine learning: how models learn from data, the four main types, how training reduces loss, and why models are tested on unseen data.
Questions readers ask
Why do I need probability for machine learning?
Machine learning always deals with uncertain, and sometimes random, quantities, and probability theory is the mathematical framework for representing uncertain statements. Models also output probabilities, and are often trained by maximum likelihood.[1][2][3][5]
What is Bayes' rule?
A formula for turning P(y given x) into P(x given y), as long as you also know P(x). It follows directly from the definition of conditional probability and is named after the Reverend Thomas Bayes.[10][9]
What does softmax do?
It turns a classification model's raw scores, called logits, into a probability for each possible class. The probabilities add up to exactly 1.[3]
What is temperature in an AI model?
A setting that controls how random a generative model's output is. Higher temperatures give more random output; lower temperatures give less random output.[4]
What is maximum likelihood?
Choosing the model parameters that make the training data most probable. In practice it means minimising the negative log-likelihood, which is the same as minimising cross-entropy.[5]
Sources
· 12 claims from 4 publishers
Each numbered claim is a statement we checked against the sources listed with it. Tap a number in the text to see its sources in place.
- [1]
Probability theory is the mathematical study of uncertainty, a framework for representing uncertain statements. confirmedas of 2026-11-22
- Review of Probability Theory (Stanford CS229 section notes) · Stanford University · Secondary source · Introduction (p. 1) (retrieved 2026-11-22)
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Chapter 3, introduction (retrieved 2026-11-22)
- [2]
The deep learning textbook says machine learning must always deal with uncertain and sometimes stochastic (nondeterministic) quantities, and that information theory lets us quantify the amount of uncertainty in a probability distribution. confirmedas of 2026-11-22
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.1 (retrieved 2026-11-22)
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Chapter 3, introduction (retrieved 2026-11-22)
- [3]
Softmax is a function that turns a classification model's raw scores into a probability for each possible class, and the probabilities add up to exactly 1.0; the raw, unnormalized scores are called logits. reportedas of 2026-11-22
- Machine Learning Glossary · Google for Developers · Secondary source · Glossary, softmax (retrieved 2026-11-07)
- Machine Learning Glossary · Google for Developers · Secondary source · Glossary, logits (retrieved 2026-11-07)
- [4]
In generative AI, temperature is a hyperparameter that controls how random a model's output is; higher temperatures give more random output and lower temperatures less random output. reportedas of 2026-11-22
- Machine Learning Glossary · Google for Developers · Secondary source · Glossary, temperature (retrieved 2026-11-07)
- [5]
Training a model by maximum likelihood, choosing parameters that make the training data most probable, amounts to minimising the negative log-likelihood, or equivalently the cross-entropy. confirmedas of 2026-11-22
- Deep Learning, Chapter 5: Machine Learning Basics (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 5.5.1 (retrieved 2026-11-22)
- Linear classification: Support Vector Machine, Softmax (Stanford CS231n course notes) · Stanford University (CS231n) · Secondary source · Softmax classifier, Probabilistic interpretation (retrieved 2026-11-22)
- [6]
The textbook distinguishes frequentist probability, tied to the rates at which events occur, from Bayesian probability, tied to qualitative levels of certainty, and says the same formulas apply to both. confirmedas of 2026-11-22
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.1 (retrieved 2026-11-22)
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.1 (retrieved 2026-11-22)
- [7]
Two simple distributions used throughout machine learning are the Bernoulli distribution, over a single yes-or-no (binary) variable controlled by one probability parameter, and the normal, or Gaussian, distribution, the most commonly used distribution over real numbers. confirmedas of 2026-11-22
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.9.1 (retrieved 2026-11-22)
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.9.3 (retrieved 2026-11-22)
- [8]
The expectation, or expected value, is the average value a quantity takes when drawn from a probability distribution; the variance measures how much the values vary around that mean, and its square root is the standard deviation. confirmedas of 2026-11-22
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.8 (retrieved 2026-11-22)
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.8 (retrieved 2026-11-22)
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.8 (retrieved 2026-11-22)
- [9]
A conditional probability is the probability of one event given that another has happened; two events are independent when observing one does not change the probability of the other. confirmedas of 2026-11-22
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.5 (retrieved 2026-11-22)
- Review of Probability Theory (Stanford CS229 section notes) · Stanford University · Secondary source · Section 1.1 (p. 2) (retrieved 2026-11-22)
- [10]
Bayes' rule computes P(x | y) from P(y | x) and P(x); it follows directly from the definition of conditional probability and is named after the Reverend Thomas Bayes, who discovered a special case of the formula. confirmedas of 2026-11-22
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.11 (retrieved 2026-11-22)
- Deep Learning, Chapter 3: Probability and Information Theory (Goodfellow, Bengio and Courville) · MIT Press (free online edition, deeplearningbook.org) · Primary source · 2016-11-18 · Section 3.11 (retrieved 2026-11-22)
- Review of Probability Theory (Stanford CS229 section notes) · Stanford University · Secondary source · Section 3.5 (p. 10) (retrieved 2026-11-22)
- [11]
Google's glossary contrasts a standard neural network, which predicts a single value such as a house price of 853,000, with a Bayesian neural network, which predicts a distribution, such as 853,000 with a standard deviation of 67,200. reportedas of 2026-11-22
- Machine Learning Glossary · Google for Developers · Secondary source · Glossary, Bayesian neural network (retrieved 2026-11-07)
- [12]
A masked language model predicts the probability of candidate tokens to fill in blanks in a sequence, such as the missing word in "The ____ in the hat came back." reportedas of 2026-11-22
- Machine Learning Glossary · Google for Developers · Secondary source · Glossary, masked language model (retrieved 2026-11-07)
Revision history (1)
- Page created.
Created Nov 22, 2026. Last reviewed by an editor on Nov 22, 2026. Next scheduled review: Jun 14, 2027.
Cite this page
"Probability for machine learning: distributions, likelihood, Bayes." ContentLora, updated Nov 22, 2026. https://contentlora.com/explain/probability-for-machine-learning
Spotted an error? Suggest a correction or emailcorrections@contentlora.com.