Skip to content

Probability Basics

The language of uncertainty that most of ML is written in: distributions, conditional probability, Bayes' rule and expected values.

Also probability · probability distribution · conditional probability · Bayes' rule · expected value · Gaussian · normal distribution

Domain 01
Foundations
Role · kind
Core ideasConcept
Level
Beginner

A weather app saying '70% chance of rain' is probability. Machine learning models talk the same way: '92% sure this email is spam', 'the next word is probably cat'.

Where it fits

+All relationships as a list

See it on the full map

How it works

Machine learning is about making good guesses under uncertainty, and probability is the math of uncertainty. You need only a handful of ideas to read most ML material.

  • Distribution: how likely each outcome is. A coin flip is a Bernoulli distribution; “which word comes next” is a categorical distribution over a vocabulary; heights follow roughly a Gaussian (bell curve).
  • Conditional probability P(A∣B)P(A \mid B): the probability of AA given that you know BB. A classifier estimates P(class∣features)P(\text{class} \mid \text{features}).
  • Bayes’ rule flips a conditional around. It powers naive Bayes spam filters and explains the classic “rare disease” puzzle.
  • Expected value: the long-run average. The loss we minimize is an expected value over the data.
  • Maximum likelihood: choose parameters that make the observed data most probable. Mean squared error corresponds to assuming Gaussian noise; log loss corresponds to a Bernoulli or categorical model.

Where you will meet it: logistic regression outputs a probability, language models output a distribution over tokens, VAEs and diffusion models learn whole data distributions, and hidden Markov models chain probabilities over time.

The math: Bayes’ rule

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

A test is 99% sensitive and 95% specific for a disease that affects 1 in 1,000 people. Of 100,000 people, about 99 of the 100 sick test positive, but so do about 5,000 of the 99,900 healthy ones. So P(sick∣+)≈99/5,094≈2%P(\text{sick} \mid +) \approx 99 / 5{,}094 \approx 2\%.

Everyday use cases

  • Case 01

    Medical tests

    Bayes' rule explains why a positive result for a rare disease can still most likely be a false alarm.

  • Case 02

    Language models

    An LLM outputs a probability distribution over the next token, and sampling picks from it.

Strengths, weaknesses and when to use it

Strengths

  • Lets models express how confident they are, not just a single answer.

Weaknesses

  • Model probabilities are often poorly calibrated, so "90% sure" may not mean right 90% of the time.

When to use itEverywhere. It is the foundation for classification outputs, loss functions, generative models and evaluation.

Check yourself

  1. Q01

    A classifier outputs P(spam) = 0.8. What is P(not spam)?

    Show answer

    B: 0.2

  2. Q02

    Minimizing cross-entropy loss is the same as...

    Show answer

    A: Maximizing the likelihood of the correct labels

Go deeper