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 Ω.
For a single roll of a six-sided die:
Each individual outcome is often denoted by a lowercase Greek letter ω. In the die example, ω could be 1, 2, 3, 4, 5, or 6.
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:
The probabilities assigned to all possible worlds must satisfy two fundamental rules.
Non-negativity
Every probability must be non-negative:
No probability may be less than 0.
Normalization
The probabilities of all mutually exclusive and exhaustive possible worlds must sum to 1:
Therefore, no individual probability can be greater than 1.
For a fair six-sided die:
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 3” 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:
For a six-sided die:
The event that the roll is less than 4 is
The event that the roll is odd is
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:
For a fair die, the probability of rolling a number less than 4 is:
Similarly:
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 A and B, its probability must agree with the probabilities assigned to those outcomes:
when A and B 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 X, Y, or T.
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 X is a function:
where:
Ω is the sample space.
X is the range of possible values of X.
For a particular possible world ω, the random variable returns a value:
Example: odd or even
Consider a die roll and the Boolean random variable O representing whether the roll is odd.
The function is deterministic:
O(1)=true
O(6)=false
However, because the die roll itself is uncertain, the value of O is uncertain before the roll occurs.
The event “the roll is odd” can be written as:
This may sometimes be abbreviated as P(O) when the meaning is clear.
Example: temperature
Let T be a random variable representing temperature, with range:
The following probabilities can then be considered:
and
The range of a random variable does not have to be finite. Examples include:
Travel time to an airport, which might range from 0 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 X:
denotes the probability that X takes the value x.
Sometimes the notation is shortened to:
where P(x) refers to the distribution over all possible values of X, 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:
For the odd-die example:
The probability distribution of O is therefore:
True: 21
False: 21
Joint Distributions
Sometimes several random variables describe the same possible world. For example, a world may include both:
Temperature T: hot or cold.
Weather W: sunny, rainy, foggy, or meteor.
A joint distribution assigns a probability to every combination of values of the variables.
For T and W, the joint distribution contains probabilities such as:
and
In shortened notation, this may be written as:
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 1.
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:
A set of random variables.
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:
Each world assigns one weather value and one temperature value.
Example: two dice
For two six-sided dice:
The first die has 6 possible values.
The second die has 6 possible values.
Therefore, the number of possible worlds is:
If both dice are fair and independent, each ordered pair has probability:
Size of the full joint distribution
If there are n variables and each variable has d possible values, the number of complete assignments is:
More generally, if the variables have different range sizes d1,d2,…,dn, the number of possible worlds is:
This growth is exponential. Even when each variable has only two values, a few hundred binary variables produce:
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 W and temperature T. To calculate the probability of a particular weather value, sum over all possible temperatures:
For example:
The variable T is summed out because it is not part of the desired marginal distribution.
Similarly:
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 A given B is defined as:
provided that P(B)>0.
Here:
P(A∣B) is the probability of A given B.
P(A,B) is the joint probability that both A and B occur.
P(B) is the probability of the condition being observed.
Intuitive interpretation
Conditioning on B restricts attention to worlds in which B is true. Within that restricted set of worlds, the conditional probability measures what fraction also satisfy A.
For example:
The denominator includes every rainy possibility:
The conditional probability is therefore the proportion of rainy worlds that are also cold.
Example calculation
If:
and:
then:
Thus, among worlds in which the temperature is cold, 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:
is the distribution over weather given that the temperature is hot.
Unlike a single conditional probability such as P(W=sunny∣T=hot), a conditional distribution contains probabilities for every possible weather value:
P(W=sunny∣T=hot)
P(W=rainy∣T=hot)
P(W=foggy∣T=hot)
P(W=meteor∣T=hot)
These probabilities must sum to 1 for the specified condition:
Normalization
A fragment of a joint distribution does not generally sum to 1. To turn it into a conditional distribution, divide every entry by the total probability of the conditioning event.
For a general variable X conditioned on Y=y:
Equivalently, each entry can be multiplied by a normalization constant α:
where:
The normalization process rescales the relevant part of the joint distribution so that its entries sum to 1.
The Product Rule
Rearranging the definition of conditional probability gives the product rule:
The same joint probability can also be expressed in the reverse direction:
These two forms are equal because both describe the same joint event.
The product rule allows a joint probability to be computed from:
The probability of the conditioning event.
The conditional probability of the other event.
For example:
Chain Rule for Probability
The product rule can be applied repeatedly to factor a joint distribution involving many variables.
For three variables:
Applying the product rule again to P(x1,x2) gives:
In general, for n variables:
For i=1, there are no preceding variables, so the first factor is simply:
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:
may be relatively high. If the agent also learns that it is early in the morning, the updated belief might be:
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 Q.
Evidence variables E.
Hidden variables H.
The goal is to compute:
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 1 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:
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) rather than 1.
Normalize them:
The denominator is obtained by summing over all possible query values:
Equivalently, a normalization constant α can be used:
where:
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:
Keep only worlds in which the weather is sunny.
For each season, sum over both possible temperatures.
Normalize the resulting values.
If the unnormalized values are:
Summer: 0.45
Winter: 0.25
then the normalization total is:
The normalized probabilities are:
and:
The normalized values sum to 1.
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:
and also:
Equating the two expressions and solving for P(A∣B) gives:
This is Bayes’ rule.
Meaning of the terms
In:
Posterior: P(A∣B) is the belief in A after observing B.
Likelihood: P(B∣A) is how likely the evidence is if A is true.
Prior: P(A) is the belief in A before observing B.
Evidence: P(B) is the overall probability of observing B.
The denominator can be expanded by marginalization:
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:
than:
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:
M means that a person has meningitis.
S means that a person has a stiff neck.
Assume:
and:
The desired probability is P(M∣S), which can be calculated using Bayes’ rule:
Substituting the values:
Therefore, the probability of meningitis given a stiff neck is 0.008, or 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 X and Y are independent if learning the value of one does not change the probability distribution of the other.
The formal definition is:
for every possible pair of values x and y.
In abbreviated notation:
Conditional form of independence
Using the product rule:
If X and Y are independent, then:
Canceling P(y) gives:
Thus, independence can also be stated as:
Observing Y does not change the probability assigned to X.
The corresponding reverse condition also holds:
Example: independent die rolls
Consider rolling a fair die twice.
The probability that the first roll is 5 and the second roll is 3 is:
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 n independent coin flips, it is unnecessary to list all:
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 X and Y are conditionally independent given Z if:
This means that once Z is known, learning Y provides no additional information about X.
Equivalently:
Example: rain, traffic, and umbrellas
Consider three variables:
R: whether it is raining.
T: whether there is traffic.
U: 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:
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.