1. Home
  2. Explore
  3. Mathematics
  4. Introduction to Probability

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Introduction to Probability

Introduction to Probability

Probability provides a formal way to represent and reason about uncertainty. It is especially important in artificial intelligence because real-world agents rarely know the complete state of the world or the exact consequences of their actions.

Logic is useful when facts and outcomes are known with certainty. However, many real-world questions cannot be answered by deduction alone:

  • If a traveler leaves an airport 60 minutes before a flight, will they arrive on time?

  • Will a tire puncture after driving over a nail?

  • How much traffic will exist on a bridge at a future time?

  • How many people will attend a particular lecture?

These outcomes depend on many variables that may be unknown, unobserved, noisy, or too complex to model exactly.


Why Uncertainty Is Necessary

Partial observability

The complete state of the world contains every relevant fact about the world at a particular time. In practice, an agent observes only a small portion of that state.

For example, an agent may not know:

  • How many people are currently on a particular bus.

  • The exact location of every vehicle.

  • The condition of every road.

  • Whether a distant event has occurred.

  • The intentions and future actions of other people.

This is called partial observability: some parts of the world are observed, while the rest remain unknown.

Noisy sensors

Even when an agent receives information, that information may be inaccurate or incomplete.

Examples include:

  • Vision that cannot clearly read a distant sign.

  • Hearing that fails to distinguish similar sounds.

  • A traffic report describing conditions at an earlier time rather than the time of interest.

  • A sensor that occasionally produces false readings.

Consequently, an agent must represent uncertainty not only about unobserved facts but also about the reliability of observed information.

Computational limitations

Even if all relevant data were available, an agent could not necessarily process it all. The state of the world may include an enormous number of facts, and reasoning about every possible interaction would be computationally infeasible.

Incomplete knowledge of how the world changes

The exact rules governing real-world events are often unknown or too complicated to model. For example, whether a tire punctures after encountering a nail may depend on:

  • The angle of contact.

  • The tire’s condition.

  • The nail’s position.

  • The vehicle’s speed.

  • The pressure in the tire.

  • Many other physical details.

It is usually impractical to represent every relevant detail explicitly.

Probability summarizes the effects of incomplete knowledge, noisy observations, computational limitations, and complicated world dynamics.

Probabilistic assertions allow an agent to say that an outcome is more or less likely without explicitly modeling every factor that contributes to it. Probability therefore represents both:

  • Objective uncertainty in the world.

  • Subjective limitations in an agent’s ability to understand the world.

Probability later supports decision theory and utility theory. An agent can select the action with the greatest expected utility by weighting the utility of each possible resulting state by the probability of reaching that state.


Probability Models

Sample spaces and possible worlds

A sample space is the set of all possible outcomes or possible worlds. It is commonly denoted by the capital Greek letter Ω\OmegaΩ.

For a single roll of a six-sided die:

Ω={1,2,3,4,5,6}\Omega = \{1,2,3,4,5,6\}Ω={1,2,3,4,5,6}

Each individual outcome is often denoted by a lowercase Greek letter ω\omegaω. In the die example, ω\omegaω could be 111, 222, 333, 444, 555, or 666.

The terms outcome, possible world, and sometimes world refer to an individual element of the sample space.

Probability models

A probability model assigns a numerical probability to every possible world:

P(ω)P(\omega)P(ω)

The probabilities assigned to all possible worlds must satisfy two fundamental rules.

Non-negativity

Every probability must be non-negative:

P(ω)≥0P(\omega) \geq 0P(ω)≥0

No probability may be less than 000.

Normalization

The probabilities of all mutually exclusive and exhaustive possible worlds must sum to 111:

∑ω∈ΩP(ω)=1\sum_{\omega \in \Omega} P(\omega) = 1∑ω∈Ω​P(ω)=1

Therefore, no individual probability can be greater than 111.

For a fair six-sided die:

P(1)=P(2)=P(3)=P(4)=P(5)=P(6)=16P(1)=P(2)=P(3)=P(4)=P(5)=P(6)=\frac{1}{6}P(1)=P(2)=P(3)=P(4)=P(5)=P(6)=61​

A different probability model could assign unequal probabilities if the die were biased.

Atomic outcomes

An atomic outcome is a possible world that cannot be divided into more detailed outcomes within the chosen model.

For a single die roll, the six numbers are atomic outcomes. The outcome “the die lands on 333” is treated as one indivisible possibility.


Events

An event is a set of possible outcomes. Formally, an event is a subset of the sample space:

E⊆ΩE \subseteq \OmegaE⊆Ω

For a six-sided die:

  • The event that the roll is less than 444 is

E={1,2,3}E = \{1,2,3\}E={1,2,3}
  • The event that the roll is odd is

O={1,3,5}O = \{1,3,5\}O={1,3,5}

Events can contain one outcome, several outcomes, or all possible outcomes.

Probability of an event

The probability of an event is the sum of the probabilities of all outcomes contained in that event:

P(E)=∑ω∈EP(ω)P(E) = \sum_{\omega \in E} P(\omega)P(E)=∑ω∈E​P(ω)

For a fair die, the probability of rolling a number less than 444 is:

P({1,2,3})=P(1)+P(2)+P(3)=16+16+16=12P(\{1,2,3\}) = P(1)+P(2)+P(3) = \frac{1}{6}+\frac{1}{6}+\frac{1}{6} = \frac{1}{2}P({1,2,3})=P(1)+P(2)+P(3)=61​+61​+61​=21​

Similarly:

P(odd)=P(1)+P(3)+P(5)=12P(\text{odd}) = P(1)+P(3)+P(5) = \frac{1}{2}P(odd)=P(1)+P(3)+P(5)=21​

Consistency and rational betting

The probability rules are not arbitrary. If a person assigns probabilities that violate non-negativity, normalization, or additivity over mutually exclusive outcomes, another person can construct a sequence of bets that guarantees a loss for the first person.

This result is related to the idea of a Dutch book: inconsistent probability assignments can be exploited because they do not represent a coherent system of beliefs.

For example, if an event consists of outcomes AAA and BBB, its probability must agree with the probabilities assigned to those outcomes:

P(A or B)=P(A)+P(B)P(A \text{ or } B)=P(A)+P(B)P(A or B)=P(A)+P(B)

when AAA and BBB are mutually exclusive. Assigning a different probability to the event would be inconsistent.


Random Variables

A random variable is a function that maps each possible world to a value. Random variables are generally written using capital letters, such as XXX, YYY, or TTT.

Although the name suggests that a random variable is itself random, the function is fixed and deterministic. The apparent randomness comes from the fact that the input possible world is uncertain.

Formal definition

A random variable XXX is a function:

X:Ω→XX:\Omega \rightarrow \mathcal{X}X:Ω→X

where:

  • Ω\OmegaΩ is the sample space.

  • X\mathcal{X}X is the range of possible values of XXX.

For a particular possible world ω\omegaω, the random variable returns a value:

X(ω)=xX(\omega)=xX(ω)=x

Example: odd or even

Consider a die roll and the Boolean random variable OOO representing whether the roll is odd.

O(ω)={trueif ω∈{1,3,5}falseif ω∈{2,4,6}O(\omega)= \begin{cases} \text{true} & \text{if } \omega \in \{1,3,5\}\\ \text{false} & \text{if } \omega \in \{2,4,6\} \end{cases}O(ω)={truefalse​if ω∈{1,3,5}if ω∈{2,4,6}​

The function is deterministic:

  • O(1)=trueO(1)=\text{true}O(1)=true

  • O(6)=falseO(6)=\text{false}O(6)=false

However, because the die roll itself is uncertain, the value of OOO is uncertain before the roll occurs.

The event “the roll is odd” can be written as:

P(O=true)P(O=\text{true})P(O=true)

This may sometimes be abbreviated as P(O)P(O)P(O) when the meaning is clear.

Example: temperature

Let TTT be a random variable representing temperature, with range:

T={hot,cold}\mathcal{T}=\{\text{hot},\text{cold}\}T={hot,cold}

The following probabilities can then be considered:

P(T=hot)P(T=\text{hot})P(T=hot)

and

P(T=cold)P(T=\text{cold})P(T=cold)

The range of a random variable does not have to be finite. Examples include:

  • Travel time to an airport, which might range from 000 to infinity.

  • A location, represented as an ordered pair of coordinates.

  • The number of people attending a lecture.

  • Weather conditions such as sunny, rainy, foggy, or meteorological extremes.


Probability Distributions

The probability distribution of a random variable specifies the probability of every value in its range.

For a random variable XXX:

P(X=x)P(X=x)P(X=x)

denotes the probability that XXX takes the value xxx.

Sometimes the notation is shortened to:

P(x)P(x)P(x)

where P(x)P(x)P(x) refers to the distribution over all possible values of XXX, not merely one isolated number.

Computing a random variable’s distribution

Because a random variable maps possible worlds to values, the probability that it takes a particular value is found by summing the probabilities of all worlds that map to that value:

P(X=x)=∑ω:X(ω)=xP(ω)P(X=x) = \sum_{\omega:X(\omega)=x}P(\omega)P(X=x)=∑ω:X(ω)=x​P(ω)

For the odd-die example:

P(O=true)=P(1)+P(3)+P(5)=12P(O=\text{true}) = P(1)+P(3)+P(5) = \frac{1}{2}P(O=true)=P(1)+P(3)+P(5)=21​

The probability distribution of OOO is therefore:

  • True: 12\frac{1}{2}21​

  • False: 12\frac{1}{2}21​


Joint Distributions

Sometimes several random variables describe the same possible world. For example, a world may include both:

  • Temperature TTT: hot or cold.

  • Weather WWW: sunny, rainy, foggy, or meteor.

A joint distribution assigns a probability to every combination of values of the variables.

For TTT and WWW, the joint distribution contains probabilities such as:

P(T=hot,W=sunny)P(T=\text{hot},W=\text{sunny})P(T=hot,W=sunny)

and

P(T=cold,W=rainy)P(T=\text{cold},W=\text{rainy})P(T=cold,W=rainy)

In shortened notation, this may be written as:

P(hot,sunny)P(\text{hot},\text{sunny})P(hot,sunny)

The complete joint distribution includes every possible combination:

  • Sunny and hot.

  • Sunny and cold.

  • Rainy and hot.

  • Rainy and cold.

  • Foggy and hot.

  • Foggy and cold.

  • Meteor and hot.

  • Meteor and cold.

All entries in the complete joint distribution sum to 111.

Marginal distributions

The individual distributions of variables that make up a joint distribution are called marginal distributions.

For example:

  • The distribution of temperature alone is a marginal distribution.

  • The distribution of weather alone is a marginal distribution.

  • The joint distribution describes both variables together.

The joint distribution contains enough information to recover the marginals. However, the marginals generally do not contain enough information to reconstruct the joint distribution.

For example, knowing how frequently it is hot and how frequently it is sunny does not determine how frequently it is both hot and sunny. The relationship between the variables is additional information.


Constructing Possible Worlds

In many machine learning applications, a model begins with:

  1. A set of random variables.

  2. The range of possible values for each variable.

A possible world is then constructed as a complete assignment of values to all variables.

Example: weather and temperature

If weather has four possible values and temperature has two possible values, then the number of possible worlds is:

4×2=84 \times 2 = 84×2=8

Each world assigns one weather value and one temperature value.

Example: two dice

For two six-sided dice:

  • The first die has 666 possible values.

  • The second die has 666 possible values.

Therefore, the number of possible worlds is:

6×6=62=366 \times 6 = 6^2 = 366×6=62=36

If both dice are fair and independent, each ordered pair has probability:

136\frac{1}{36}361​

Size of the full joint distribution

If there are nnn variables and each variable has ddd possible values, the number of complete assignments is:

dnd^ndn

More generally, if the variables have different range sizes d1,d2,…,dnd_1,d_2,\ldots,d_nd1​,d2​,…,dn​, the number of possible worlds is:

∏i=1ndi\prod_{i=1}^{n}d_i∏i=1n​di​

This growth is exponential. Even when each variable has only two values, a few hundred binary variables produce:

2数百2^{\text{数百}}2数百

possible worlds, which is far too many to list explicitly.

For example, whether each student attends a lecture could be represented with one binary variable per student. With several hundred students, the complete attendance distribution would require an entry for every possible attendance pattern. This is computationally infeasible, especially when attendance variables may also be correlated.

This exponential growth motivates more compact representations such as Bayesian networks, which exploit conditional independence.


Marginalization

Marginalization is the process of obtaining a distribution over a subset of variables by summing out variables that are not of interest.

Suppose the joint distribution includes weather WWW and temperature TTT. To calculate the probability of a particular weather value, sum over all possible temperatures:

P(W=w)=∑tP(W=w,T=t)P(W=w)=\sum_tP(W=w,T=t)P(W=w)=∑t​P(W=w,T=t)

For example:

P(W=sunny)=P(W=sunny,T=hot)+P(W=sunny,T=cold)P(W=\text{sunny}) = P(W=\text{sunny},T=\text{hot}) + P(W=\text{sunny},T=\text{cold})P(W=sunny)=P(W=sunny,T=hot)+P(W=sunny,T=cold)

The variable TTT is summed out because it is not part of the desired marginal distribution.

Similarly:

P(T=t)=∑wP(W=w,T=t)P(T=t)=\sum_wP(W=w,T=t)P(T=t)=∑w​P(W=w,T=t)

The summation is conceptually simple: every way of obtaining the desired value must be included.


Conditional Probability

A conditional probability describes the probability of one event given that another event is known to have occurred.

The conditional probability of AAA given BBB is defined as:

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

provided that P(B)>0P(B)>0P(B)>0.

Here:

  • P(A∣B)P(A\mid B)P(A∣B) is the probability of AAA given BBB.

  • P(A,B)P(A,B)P(A,B) is the joint probability that both AAA and BBB occur.

  • P(B)P(B)P(B) is the probability of the condition being observed.

Intuitive interpretation

Conditioning on BBB restricts attention to worlds in which BBB is true. Within that restricted set of worlds, the conditional probability measures what fraction also satisfy AAA.

For example:

P(cold∣rainy)=P(cold,rainy)P(rainy)P(\text{cold}\mid\text{rainy}) = \frac{P(\text{cold},\text{rainy})} {P(\text{rainy})}P(cold∣rainy)=P(rainy)P(cold,rainy)​

The denominator includes every rainy possibility:

P(rainy)=P(cold,rainy)+P(hot,rainy)P(\text{rainy}) = P(\text{cold},\text{rainy}) + P(\text{hot},\text{rainy})P(rainy)=P(cold,rainy)+P(hot,rainy)

The conditional probability is therefore the proportion of rainy worlds that are also cold.

Example calculation

If:

P(sunny,cold)=0.15P(\text{sunny},\text{cold})=0.15P(sunny,cold)=0.15

and:

P(cold)=0.5P(\text{cold})=0.5P(cold)=0.5

then:

P(sunny∣cold)=0.150.5=0.3P(\text{sunny}\mid\text{cold}) = \frac{0.15}{0.5} = 0.3P(sunny∣cold)=0.50.15​=0.3

Thus, among worlds in which the temperature is cold, 30%30\%30% are sunny.


Conditional Distributions

A conditional distribution gives an entire probability distribution over one variable after conditioning on a value of another variable.

For example:

P(W∣T=hot)P(W\mid T=\text{hot})P(W∣T=hot)

is the distribution over weather given that the temperature is hot.

Unlike a single conditional probability such as P(W=sunny∣T=hot)P(W=\text{sunny}\mid T=\text{hot})P(W=sunny∣T=hot), a conditional distribution contains probabilities for every possible weather value:

  • P(W=sunny∣T=hot)P(W=\text{sunny}\mid T=\text{hot})P(W=sunny∣T=hot)

  • P(W=rainy∣T=hot)P(W=\text{rainy}\mid T=\text{hot})P(W=rainy∣T=hot)

  • P(W=foggy∣T=hot)P(W=\text{foggy}\mid T=\text{hot})P(W=foggy∣T=hot)

  • P(W=meteor∣T=hot)P(W=\text{meteor}\mid T=\text{hot})P(W=meteor∣T=hot)

These probabilities must sum to 111 for the specified condition:

∑wP(W=w∣T=hot)=1\sum_wP(W=w\mid T=\text{hot})=1∑w​P(W=w∣T=hot)=1

Normalization

A fragment of a joint distribution does not generally sum to 111. To turn it into a conditional distribution, divide every entry by the total probability of the conditioning event.

For a general variable XXX conditioned on Y=yY=yY=y:

P(X=x∣Y=y)=P(X=x,Y=y)P(Y=y)P(X=x\mid Y=y) = \frac{P(X=x,Y=y)}{P(Y=y)}P(X=x∣Y=y)=P(Y=y)P(X=x,Y=y)​

Equivalently, each entry can be multiplied by a normalization constant α\alphaα:

P(X=x∣Y=y)=αP(X=x,Y=y)P(X=x\mid Y=y)=\alpha P(X=x,Y=y)P(X=x∣Y=y)=αP(X=x,Y=y)

where:

α=1P(Y=y)\alpha=\frac{1}{P(Y=y)}α=P(Y=y)1​

The normalization process rescales the relevant part of the joint distribution so that its entries sum to 111.


The Product Rule

Rearranging the definition of conditional probability gives the product rule:

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

The same joint probability can also be expressed in the reverse direction:

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

These two forms are equal because both describe the same joint event.

The product rule allows a joint probability to be computed from:

  1. The probability of the conditioning event.

  2. The conditional probability of the other event.

For example:

P(T=hot,W=rainy)=P(W=rainy∣T=hot)P(T=hot)P(T=\text{hot},W=\text{rainy}) = P(W=\text{rainy}\mid T=\text{hot})P(T=\text{hot})P(T=hot,W=rainy)=P(W=rainy∣T=hot)P(T=hot)

Chain Rule for Probability

The product rule can be applied repeatedly to factor a joint distribution involving many variables.

For three variables:

P(x1,x2,x3)=P(x3∣x1,x2)P(x1,x2)P(x_1,x_2,x_3) = P(x_3\mid x_1,x_2)P(x_1,x_2)P(x1​,x2​,x3​)=P(x3​∣x1​,x2​)P(x1​,x2​)

Applying the product rule again to P(x1,x2)P(x_1,x_2)P(x1​,x2​) gives:

P(x1,x2,x3)=P(x3∣x1,x2)P(x2∣x1)P(x1)P(x_1,x_2,x_3) = P(x_3\mid x_1,x_2) P(x_2\mid x_1) P(x_1)P(x1​,x2​,x3​)=P(x3​∣x1​,x2​)P(x2​∣x1​)P(x1​)

In general, for nnn variables:

P(x1,x2,…,xn)=∏i=1nP(xi∣x1,…,xi−1)P(x_1,x_2,\ldots,x_n) = \prod_{i=1}^{n} P(x_i\mid x_1,\ldots,x_{i-1})P(x1​,x2​,…,xn​)=∏i=1n​P(xi​∣x1​,…,xi−1​)

For i=1i=1i=1, there are no preceding variables, so the first factor is simply:

P(x1)P(x_1)P(x1​)

The chain rule is valid for any ordering of the variables. A convenient ordering may make the conditional distributions easier to represent or compute.


Evidence and Belief Updating

In probabilistic inference, some variables are observed and others are not.

Query variables

Query variables are the variables whose probabilities are of interest.

Example:

  • Whether a traveler arrives at the airport on time.

Evidence variables

Evidence variables are variables whose values have been observed.

Example:

  • Whether there is an accident.

  • Whether it is currently raining.

  • The current time.

Hidden variables

Hidden variables are relevant variables that are neither directly observed nor the primary subject of the query.

Example:

  • Temperature when the query concerns weather and the evidence is a season.

Observing new evidence changes the probabilities assigned to possible outcomes. This process is called belief updating or conditioning.

For example:

P(on time∣no accidents)P(\text{on time}\mid\text{no accidents})P(on time∣no accidents)

may be relatively high. If the agent also learns that it is early in the morning, the updated belief might be:

P(on time∣no accidents,early morning)P(\text{on time}\mid\text{no accidents},\text{early morning})P(on time∣no accidents,early morning)

If traffic is usually lighter early in the morning, the probability may increase. If the agent then learns that a major road is closed, the probability may decrease.

New evidence does not necessarily make a probability higher or lower in every case; it changes the belief according to how the evidence relates to the outcome.


Inference by Enumeration

Inference by enumeration computes probabilities directly from a complete joint distribution.

Suppose the variables are divided into:

  • Query variables QQQ.

  • Evidence variables EEE.

  • Hidden variables HHH.

The goal is to compute:

P(Q∣E)P(Q\mid E)P(Q∣E)

The procedure has three main stages.

Step 1: Select worlds consistent with the evidence

Only possible worlds in which the observed evidence is true are retained. Worlds inconsistent with the evidence are discarded.

The remaining probabilities usually sum to less than 111 because the discarded worlds are no longer included.

Step 2: Sum out hidden variables

If hidden variables are not part of the query, sum over all their possible values:

P(Q,E)=∑HP(Q,E,H)P(Q,E)=\sum_H P(Q,E,H)P(Q,E)=∑H​P(Q,E,H)

This produces values associated with the query and evidence variables while removing the hidden variables.

Step 3: Normalize

The resulting values are not yet a complete conditional distribution because they sum to P(E)P(E)P(E) rather than 111.

Normalize them:

P(Q∣E)=P(Q,E)P(E)P(Q\mid E) = \frac{P(Q,E)}{P(E)}P(Q∣E)=P(E)P(Q,E)​

The denominator is obtained by summing over all possible query values:

P(E)=∑QP(Q,E)P(E)=\sum_QP(Q,E)P(E)=∑Q​P(Q,E)

Equivalently, a normalization constant α\alphaα can be used:

P(Q∣E)=αP(Q,E)P(Q\mid E)=\alpha P(Q,E)P(Q∣E)=αP(Q,E)

where:

α=1P(E)\alpha=\frac{1}{P(E)}α=P(E)1​

Example: season given sunny weather

Suppose a model contains:

  • Season: summer or winter.

  • Temperature: hot or cold.

  • Weather: sunny or another condition.

To calculate the distribution over season given that it is sunny:

  1. Keep only worlds in which the weather is sunny.

  2. For each season, sum over both possible temperatures.

  3. Normalize the resulting values.

If the unnormalized values are:

  • Summer: 0.450.450.45

  • Winter: 0.250.250.25

then the normalization total is:

0.45+0.25=0.700.45+0.25=0.700.45+0.25=0.70

The normalized probabilities are:

P(summer∣sunny)=0.450.70P(\text{summer}\mid\text{sunny}) = \frac{0.45}{0.70}P(summer∣sunny)=0.700.45​

and:

P(winter∣sunny)=0.250.70P(\text{winter}\mid\text{sunny}) = \frac{0.25}{0.70}P(winter∣sunny)=0.700.25​

The normalized values sum to 111.

Why enumeration is impractical

Inference by enumeration has serious limitations.

Exponential computation

If there are many hidden variables, enumeration must consider every combination of their values. The time complexity is exponential in the number of hidden variables.

Exponential storage

Storing the complete joint distribution requires one entry for every possible world. With many binary variables, this requires exponentially many entries.

Exponential data requirements

Even if a complete table could be stored, estimating every entry from real-world observations would require an enormous amount of data. Rare combinations might never be observed enough times to estimate their probabilities reliably.

These limitations motivate compact probabilistic representations based on independence and conditional independence.


Bayes’ Rule

Bayes’ rule is derived directly from the product rule.

Starting with:

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

and also:

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

Equating the two expressions and solving for P(A∣B)P(A\mid B)P(A∣B) gives:

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

This is Bayes’ rule.

Meaning of the terms

In:

P(A∣B)=P(B∣A)P(A)P(B)P(A\mid B) = \frac{P(B\mid A)P(A)}{P(B)}P(A∣B)=P(B)P(B∣A)P(A)​
  • Posterior: P(A∣B)P(A\mid B)P(A∣B) is the belief in AAA after observing BBB.

  • Likelihood: P(B∣A)P(B\mid A)P(B∣A) is how likely the evidence is if AAA is true.

  • Prior: P(A)P(A)P(A) is the belief in AAA before observing BBB.

  • Evidence: P(B)P(B)P(B) is the overall probability of observing BBB.

The denominator can be expanded by marginalization:

P(B)=∑aP(B∣A=a)P(A=a)P(B)=\sum_aP(B\mid A=a)P(A=a)P(B)=∑a​P(B∣A=a)P(A=a)

Thus, Bayes’ rule updates a prior belief using evidence.

Why Bayes’ rule is useful

Often, the probability in one direction is easier to obtain than the probability in the reverse direction.

For example, it may be easier to determine:

P(symptom∣disease)P(\text{symptom}\mid\text{disease})P(symptom∣disease)

than:

P(disease∣symptom)P(\text{disease}\mid\text{symptom})P(disease∣symptom)

Medical data may reveal how commonly a symptom occurs among people with a disease. Bayes’ rule uses that information to infer how likely the disease is for someone who has the symptom.

Similarly, it may be easier to know the probability of an effect given a cause than to infer the cause from an observed effect.


Priors, Base Rates, and Diagnostic Reasoning

Suppose:

  • MMM means that a person has meningitis.

  • SSS means that a person has a stiff neck.

Assume:

P(M)=110,000P(M)=\frac{1}{10{,}000}P(M)=10,0001​
P(S)=1100P(S)=\frac{1}{100}P(S)=1001​

and:

P(S∣M)=0.8P(S\mid M)=0.8P(S∣M)=0.8

The desired probability is P(M∣S)P(M\mid S)P(M∣S), which can be calculated using Bayes’ rule:

P(M∣S)=P(S∣M)P(M)P(S)P(M\mid S) = \frac{P(S\mid M)P(M)}{P(S)}P(M∣S)=P(S)P(S∣M)P(M)​

Substituting the values:

P(M∣S)=0.8⋅110,0001100=0.008P(M\mid S) = \frac{0.8\cdot\frac{1}{10{,}000}}{\frac{1}{100}} = 0.008P(M∣S)=1001​0.8⋅10,0001​​=0.008

Therefore, the probability of meningitis given a stiff neck is 0.0080.0080.008, or 0.8%0.8\%0.8%.

A stiff neck is common among people with meningitis, but meningitis itself is rare. Many more people have stiff necks for ordinary reasons than have meningitis.

A symptom can be strongly associated with a disease while the disease remains unlikely given the symptom.

This illustrates the importance of base rates or prior probabilities. A common reasoning error is to focus on how typical the evidence is under a hypothesis while ignoring how likely the hypothesis was before the evidence appeared.

The same principle applies to broader reasoning problems. A detailed description may sound highly representative of a particular category, but if that category is rare, its posterior probability may still be lower than that of a broader and more common category.

Evidence can substantially increase a belief without making the belief likely overall. In the meningitis example, the stiff neck increases the probability relative to the prior, but the final probability remains small.


Independence

Two random variables XXX and YYY are independent if learning the value of one does not change the probability distribution of the other.

The formal definition is:

P(X=x,Y=y)=P(X=x)P(Y=y)P(X=x,Y=y)=P(X=x)P(Y=y)P(X=x,Y=y)=P(X=x)P(Y=y)

for every possible pair of values xxx and yyy.

In abbreviated notation:

P(x,y)=P(x)P(y)P(x,y)=P(x)P(y)P(x,y)=P(x)P(y)

Conditional form of independence

Using the product rule:

P(x,y)=P(x∣y)P(y)P(x,y)=P(x\mid y)P(y)P(x,y)=P(x∣y)P(y)

If XXX and YYY are independent, then:

P(x)P(y)=P(x∣y)P(y)P(x)P(y)=P(x\mid y)P(y)P(x)P(y)=P(x∣y)P(y)

Canceling P(y)P(y)P(y) gives:

P(x∣y)=P(x)P(x\mid y)=P(x)P(x∣y)=P(x)

Thus, independence can also be stated as:

Observing YYY does not change the probability assigned to XXX.

The corresponding reverse condition also holds:

P(y∣x)=P(y)P(y\mid x)=P(y)P(y∣x)=P(y)

Example: independent die rolls

Consider rolling a fair die twice.

The probability that the first roll is 555 and the second roll is 333 is:

P(roll1=5,roll2=3)=P(roll1=5)P(roll2=3)=16⋅16=136P(\text{roll}_1=5,\text{roll}_2=3) = P(\text{roll}_1=5)P(\text{roll}_2=3) = \frac{1}{6}\cdot\frac{1}{6} = \frac{1}{36}P(roll1​=5,roll2​=3)=P(roll1​=5)P(roll2​=3)=61​⋅61​=361​

The result of the first roll does not affect the probability distribution of the second roll.

Benefits of independence

Independence allows a large joint distribution to be represented compactly.

For nnn independent coin flips, it is unnecessary to list all:

2n2^n2n

possible sequences. Instead, it is enough to specify the distribution of an individual flip and state that the flips are independent.

Independence therefore provides an exponential reduction in representation size.


Conditional Independence

Complete independence between pairs of variables is often unrealistic. Many real-world variables are related indirectly through other variables.

Conditional independence occurs when two variables become independent after conditioning on a third variable or set of variables.

Variables XXX and YYY are conditionally independent given ZZZ if:

P(X∣Y,Z)=P(X∣Z)P(X\mid Y,Z)=P(X\mid Z)P(X∣Y,Z)=P(X∣Z)

This means that once ZZZ is known, learning YYY provides no additional information about XXX.

Equivalently:

P(X,Y∣Z)=P(X∣Z)P(Y∣Z)P(X,Y\mid Z)=P(X\mid Z)P(Y\mid Z)P(X,Y∣Z)=P(X∣Z)P(Y∣Z)

Example: rain, traffic, and umbrellas

Consider three variables:

  • RRR: whether it is raining.

  • TTT: whether there is traffic.

  • UUU: whether a person carries an umbrella.

No pair may be unconditionally independent:

  • Seeing an umbrella increases the probability that it is raining.

  • Knowing that it is raining may increase the probability of traffic.

  • Seeing traffic may provide indirect information about rain.

  • Seeing an umbrella may therefore indirectly provide information about traffic.

However, once the fact of rain is known, the umbrella and traffic may become conditionally independent:

P(U∣T,R)=P(U∣R)P(U\mid T,R)=P(U\mid R)P(U∣T,R)=P(U∣R)

If it is already known that it is raining, learning that a person carries an umbrella may not provide additional information about traffic. Both umbrella use and traffic are explained by the known rain condition.

Importance of conditional independence

Conditional independence is the central idea behind compact probabilistic models such as Bayesian networks.

It allows a model to represent a large number of uncertain variables without storing every entry in the full joint distribution. Instead of explicitly describing every possible combination, the model records the smaller conditional relationships that connect variables.

This makes probabilistic inference more computationally tractable while preserving important dependencies between variables.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent