Introduction to Probability
Foundations of Probability
Probability provides a formal language for reasoning when the complete state of the world is unknown, observations are imperfect, and the consequences of actions depend on uncertain outcomes. It will later support tools such as Bayes’ nets, probabilistic inference, utility theory, and decision-making.
The central idea is simple: instead of pretending that the world is completely known, a reasoning system assigns degrees of belief to different possibilities and updates those beliefs as evidence arrives.
Why Probability Is Needed
Logic is powerful when the relevant facts are known and the rules governing them are certain. For example, in a search problem, an agent may know:
- Its exact current state
- The goal state
- The available actions
- The result of each action
- The possible states along the way
Real-world reasoning is rarely so complete. Suppose a traveler leaves an airport sixty minutes before a flight. Will the traveler arrive on time? The answer depends on many uncertain factors:
- The amount of traffic
- Whether an accident occurs
- How accurately traffic reports describe current conditions
- Whether the traveler encounters an unexpected delay
- How the vehicle behaves
- Whether the route is affected by construction or congestion
These factors cannot usually be deduced with certainty from the information available. Sometimes the traveler will arrive on time, and sometimes not.
Partial Observability
The state of the world contains every fact about the world at a particular moment. Almost no agent knows the entire state. For example, an agent may not know how many people are currently riding a particular bus, what every person is doing, or what is happening in distant locations.
Instead, an agent observes only some pieces of the world. This situation is called partial observability: part of the state is observed, while the rest remains unknown.
Noisy Sensors
Even observed information may not be perfectly reliable. Human vision, hearing, cameras, microphones, and radio reports all provide incomplete or imprecise information.
For example, a person may see a red sign but be unable to read all of its words. A traffic report may describe the traffic at one time, while the traveler cares about traffic at a later time. The report is relevant, but it does not perfectly reveal the future condition.
A sensor is therefore noisy when its observation does not provide a perfectly accurate description of the underlying situation.
Limited Computational Resources
Even if an agent could obtain every fact about the world, the amount of information might be too large to process. The agent cannot consider every relevant detail of every possible situation.
This means that probability is useful not only because the world itself contains genuine randomness, but also because an agent has limited knowledge, time, memory, and computational ability. Probabilistic statements summarize the effects of ignorance and simplification.
Probability allows an agent to represent uncertainty caused both by the world’s unpredictability and by the agent’s limited ability to observe and model the world.
Probability will eventually connect to decision-making. An agent can evaluate an action by considering the utility of each possible resulting state and weighting that utility by the probability of reaching the state. The agent then chooses the action with the greatest expected utility.
Think About It
Why might probability be useful even in a world that is completely deterministic? The world could follow fixed physical laws, but an agent would still need probability if it lacked complete information or could not compute every detail.
Possible Worlds and Probability Models
Probability begins with a set of possible worlds, written as Ω.
A possible world is one complete way the relevant part of the world could be. An individual possible world is often written as ω.
For a single roll of a six-sided die, the possible worlds are:
Ω={1,2,3,4,5,6}Each element represents one atomic outcome: the die lands on 1, the die lands on 2, and so on.
An atomic outcome is a possibility that is not divided into smaller possibilities within the model. In the die example, each individual die value is atomic.
A probability model assigns a numerical probability to every possible world. For a fair die:
P(1)=P(2)=P(3)=P(4)=P(5)=P(6)=61The probabilities in any valid model must obey two basic rules:
- Every probability is non-negative:
- The probabilities of all possible worlds sum to 1:
Because the total is 1, no individual probability can be greater than 1.
The model need not assign equal probabilities to all outcomes. Equal probabilities make sense for a fair die, but a model for a biased die could assign larger probabilities to some faces than others. The essential requirements are non-negativity and a total of 1.
Events
An event is a set of possible worlds. In set notation, an event is a subset of Ω.
For a die roll, the event “the result is less than 4” is:
A={1,2,3}The event “the result is odd” is:
B={1,3,5}The probability of an event is the sum of the probabilities of all the atomic outcomes contained in that event:
P(A)=ω∈A∑P(ω)For a fair die:
P(less than 4)=P(1)+P(2)+P(3)=61+61+61=21Similarly:
P(odd)=P(1)+P(3)+P(5)=21The event itself may contain several possible worlds, but the atomic worlds are the basic units to which the probability model directly assigns values.
Why the Probability Rules Matter
The probability of a combined event must equal the sum of the probabilities of the atomic outcomes making up that event. If a person assigned probabilities that violated these rules, the assignments would not behave coherently.
One reason is that inconsistent probability assignments can be exploited through a sequence of bets. A person whose probabilities do not obey the standard rules could be offered a collection of bets that guarantees a financial loss, assuming the person accepts bets according to those inconsistent beliefs. This idea is sometimes called a Dutch book argument.
The important lesson is that the probability rules are not merely an arbitrary notation system. They provide a consistent way to represent uncertainty.
Think About It
If an event contains the outcomes 1, 2, and 3, why must its probability equal P(1)+P(2)+P(3)? Each atomic outcome is mutually exclusive with the others, so exactly one of them occurs in a single die roll.
Random Variables
A random variable represents some aspect of a possible world whose value is uncertain before the world is known.
Random variables are usually written with capital letters, such as X, Y, or T. A particular value is written with a lowercase letter, such as x, y, or t.
Despite its name, a random variable is formally neither random nor variable in the function itself. It is a deterministic function from possible worlds to values. The randomness comes from the fact that the actual possible world is uncertain.
Example: An Oddness Variable
Consider a die roll and define a Boolean random variable called Odd:
Odd:Ω→{true,false}The function maps possible worlds to truth values:
- Odd(1)=true
- Odd(3)=true
- Odd(5)=true
- Odd(2)=false
- Odd(4)=false
- Odd(6)=false
The function itself is fixed. However, because the die outcome is uncertain, the output of the function is uncertain as well.
The probability that the die is odd can be written as:
P(Odd=true)It may also be abbreviated as:
P(Odd)when the intended value is clear.
Ranges of Random Variables
The range of a random variable is the set of values that it can output.
For a temperature variable T, the range might be:
{hot,cold}For a travel-time variable, the range could include any nonnegative real value:
[0,∞)For a location variable, the range might be a set of ordered pairs of integers representing possible locations.
The range can therefore be finite or infinite, discrete or continuous, depending on what the variable represents.
Probability Distributions of Random Variables
A probability distribution for a random variable gives the probability of each value in its range.
For a random variable X, the probability that it takes the value x is:
P(X=x)This probability is found by adding the probabilities of all possible worlds that the random variable maps to x:
P(X=x)=ω:X(ω)=x∑P(ω)The notation ω:X(ω)=x means that the sum includes every possible world for which the function X returns x.
For the oddness variable:
P(Odd=true)=P(1)+P(3)+P(5)=21A compact notation often writes P(x) instead of P(X=x) when the random variable is understood. The notation P(X) can refer to the entire probability distribution over all values of X, not merely one numerical probability.
Joint Distributions
Often, several uncertain quantities exist at the same time. For example, a situation may have both:
- A temperature variable T
- A weather variable W
The temperature might be hot or cold. The weather might be sunny, rainy, foggy, or affected by some other modeled condition.
A joint distribution assigns a probability to every combination of values of the variables. For example:
P(W=sunny,T=hot)represents the probability that it is both sunny and hot.
A joint distribution over W and T includes entries such as:
P(sunny,hot)P(sunny,cold)P(rainy,hot)P(rainy,cold)P(foggy,hot)P(foggy,cold)and any other combinations included in the model.
The individual distributions over W and T are called marginal distributions of the joint distribution. The joint distribution contains information about how the variables relate to each other.
A crucial relationship is asymmetric:
- The marginals can be computed from the joint distribution.
- The joint distribution generally cannot be reconstructed from the marginals alone.
For example, knowing the overall probability of sunny weather and the overall probability of hot temperature does not reveal how often sunny and hot occur together. Different joint distributions can have the same marginals but different relationships between the variables.
Constructing Possible Worlds from Variables
In many machine-learning models, possible worlds are constructed by assigning a value to every random variable.
If the variables are temperature and weather, one possible world might be:
T=hot,W=sunnyAnother might be:
T=cold,W=rainyEach complete assignment of values is one possible world in Ω.
For two dice rolls, each die has six possible values. A possible world is a pair such as:
(roll1=2,roll2=5)The number of possible worlds is:
6×6=62=36If both dice are fair and independent, each pair has probability:
361The Size of a Joint Distribution
Suppose there are n variables and each variable has d possible values. The number of complete assignments is:
dnThis growth is exponential. Even moderate numbers of variables can produce enormous joint distributions.
For example, if each of several hundred students either attends or does not attend a lecture, each student contributes two possibilities. The number of attendance patterns is:
2nwhere n is the number of students. A complete table would require assigning a probability to every one of those patterns, which quickly becomes impossible to store or learn from data.
This is one of the central computational problems in probability: a full joint distribution can contain far more entries than an agent can reasonably represent or estimate.
Think About It
Why does adding variables create such a large problem? Each new variable combines with every existing assignment, multiplying the number of possible worlds rather than merely adding a few more possibilities.
Marginalization
Marginalization means summing over values of variables that are not relevant to the question.
Suppose a joint distribution describes weather and temperature, and the goal is to find the probability that the weather is sunny. Temperature is not part of the question, so all temperature possibilities must be added:
P(W=sunny)=t∑P(W=sunny,T=t)If temperature has the values hot and cold, this becomes:
P(W=sunny)=P(sunny,hot)+P(sunny,cold)The same procedure applies to any event. The probability of an event is found by summing the probabilities of all complete worlds in which the event is true.
For example, if the desired event is “hot,” every weather value paired with hot must be included:
P(T=hot)=w∑P(T=hot,W=w)Marginalization is intuitive because it accounts for every way the event of interest can occur.
Conditional Probability
A conditional probability describes the probability of one event given that another event is known to be true.
The conditional probability of A given B is defined as:
P(A∣B)=P(B)P(A,B)The notation P(A∣B) is read as “the probability of A given B.”
The denominator P(B) restricts attention to worlds where B is true. The numerator P(A,B) counts the worlds where both A and B are true. Thus, conditional probability asks:
Among the worlds consistent with B, what fraction also satisfy A?
For example, the probability of cold given rainy is:
P(cold∣rainy)=P(rainy)P(cold,rainy)The denominator can be found by marginalizing over temperature:
P(rainy)=P(rainy,hot)+P(rainy,cold)Conditional Distributions
A conditional probability distribution gives a full distribution for one variable after another variable is fixed.
For example:
P(W∣T=hot)is the distribution over weather when the temperature is known to be hot. It includes probabilities such as:
P(W=sunny∣T=hot)and
P(W=rainy∣T=hot)A conditional distribution must sum to 1 over the possible values of the variable being distributed. A column or row taken from a joint table may sum to less than 1, so it must be normalized.
Normalization means dividing each relevant joint probability by the total probability of the condition. For example:
P(W=w∣T=hot)=P(T=hot)P(W=w,T=hot)Equivalently, each entry can be multiplied by a normalization constant α:
α=∑wP(W=w,T=hot)1The normalized distribution is then:
P(W=w∣T=hot)=αP(W=w,T=hot)A conditional distribution differs from a joint distribution. A joint distribution over all combinations sums to 1 across the entire table. A conditional distribution sums to 1 separately for each fixed condition.
The Product Rule
Rearranging the definition of conditional probability gives the product rule:
P(A,B)=P(A∣B)P(B)The same joint probability can also be written in the opposite order:
P(A,B)=P(B∣A)P(A)The product rule allows a joint probability to be computed by multiplying a conditional probability by the probability of the condition.
For example:
P(W=rainy,T=hot)=P(W=rainy∣T=hot)P(T=hot)This provides a way to construct a joint distribution from:
- A distribution over one variable
- A conditional distribution over another variable given the first
The Chain Rule
The product rule extends to any number of variables. For three variables:
P(X1,X2,X3)=P(X3∣X1,X2)P(X1,X2)Applying the product rule again gives:
P(X1,X2,X3)=P(X3∣X1,X2)P(X2∣X1)P(X1)For n variables, the general form is:
P(x1,x2,…,xn)=i=1∏nP(xi∣x1,…,xi−1)For the first variable, there are no previous variables, so the first factor is simply:
P(x1)The chain rule is valid for any ordering of the variables. A convenient ordering can make a probability model easier to express.
Evidence and Updating Beliefs
In probabilistic inference, some variables represent information that has been observed, while other variables represent questions of interest.
- Evidence variables are variables whose values have been observed.
- Query variables are variables whose probabilities are being requested.
- Hidden variables are unobserved variables that may influence the relationship between the evidence and the query.
Suppose an agent wants the probability of arriving at an airport on time given that there are no accidents. The absence of accidents is evidence, and arriving on time is the query.
As new evidence arrives, beliefs can change. For example, if the agent also learns that it is very early in the morning, the probability of arriving on time may increase because the roads may be less crowded. If the agent learns that heavy rain has begun, the probability may decrease.
Conditioning is the mathematical operation used to incorporate evidence. Observing evidence means restricting attention to worlds consistent with that evidence and then renormalizing the remaining probabilities.
Inference by Enumeration
The most direct inference method begins with a complete joint distribution.
Suppose the goal is to find a distribution over query variables Q given evidence E, while hidden variables H are not observed.
The process has three main steps.
Step 1: Select Evidence-Consistent Worlds
The model keeps only worlds in which the evidence has the observed values. Worlds inconsistent with the evidence are discarded.
The remaining entries represent possible worlds that could still be true.
Step 2: Sum Out Hidden Variables
The hidden variables are irrelevant to the final answer, so their values are summed out:
P(Q,E)=H∑P(Q,E,H)This produces values for the query and evidence variables, but the values may not yet form a valid probability distribution because the entries may sum to less than 1.
Step 3: Normalize
The remaining values are divided by their total so that they sum to 1:
P(Q∣E)=αP(Q,E)where α is the normalization constant:
α=∑QP(Q,E)1The same procedure can be understood intuitively. Once evidence is observed, the probability mass outside the evidence-consistent worlds is removed. Normalization expands the remaining mass so that the surviving worlds again account for the entire probability distribution.
Example of Inference by Enumeration
Suppose a model includes:
- Season
- Temperature
- Weather
The goal is to find the probability distribution over season given that the weather is sunny.
First, all worlds in which the weather is not sunny are removed. The remaining entries represent sunny worlds, but they may sum to less than 1.
Next, temperature is hidden and irrelevant, so the entries for hot and cold are added together for each season:
P(summer,sunny)=t∑P(summer,t,sunny)and similarly for winter.
Finally, the resulting values are normalized. If the unnormalized values are 0.45 and 0.25, the total is:
0.45+0.25=0.70The normalized probabilities are:
P(summer∣sunny)=0.700.45and
P(winter∣sunny)=0.700.25These normalized values sum to 1.
Problems with Enumeration
Inference by enumeration is conceptually straightforward but computationally expensive.
Its main problems are:
- The number of hidden-variable assignments can grow exponentially.
- The full joint distribution may be too large to store.
- Learning every entry from data may require an impractically large number of observations.
If a joint table has exponentially many entries, then collecting enough data to estimate every entry may also require exponentially many observations. Real-world data collection costs time and money, so filling such a table is generally infeasible.
These problems motivate more compact representations, including Bayes’ nets and conditional independence.
Think About It
Why are hidden variables expensive in enumeration? Every possible combination of their values must be considered, even though the final answer may not mention those variables at all.
Bayes’ Rule
Bayes’ rule follows directly from the product rule. The two equivalent expressions for a joint probability are:
P(A,B)=P(A∣B)P(B)and
P(A,B)=P(B∣A)P(A)Setting them equal and solving for P(A∣B) gives:
P(A∣B)=P(B)P(B∣A)P(A)This is Bayes’ rule.
Bayes’ rule is especially useful when P(B∣A) is easier to determine than P(A∣B). In many applications, it is easier to understand the probability of an observation given a hypothesis than the probability of the hypothesis given the observation.
The terms often have the following meanings:
- P(A): the prior probability, or belief in A before observing B
- P(B∣A): the likelihood of observing B if A is true
- P(B): the overall probability of the evidence
- P(A∣B): the updated or posterior probability of A after observing B
Hypotheses and Data
Let H represent a hypothesis and D represent observed data:
P(H∣D)=P(D)P(D∣H)P(H)The hypothesis might be an illness, a scientific explanation, or a possible cause. The data is an observation that may support or weaken the hypothesis.
The denominator can be found by summing over all possible hypotheses:
P(D)=h∑P(D∣h)P(h)Thus:
P(H∣D)=∑hP(D∣h)P(h)P(D∣H)P(H)Medical Example
Suppose a person has a stiff neck and wants to know whether meningitis is the cause.
The relevant information might be:
P(meningitis)=10,0001 P(stiff neck)=1001and
P(stiff neck∣meningitis)=0.8Bayes’ rule gives:
P(meningitis∣stiff neck)=P(stiff neck)P(stiff neck∣meningitis)P(meningitis)Substituting the values:
P(meningitis∣stiff neck)=10010.8⋅10,0001=0.008The result is 0.008, or 0.8%.
A stiff neck is common among people with meningitis, but meningitis is rare among the general population. Therefore, a stiff neck raises the probability of meningitis substantially relative to its prior probability, yet the resulting probability remains small.
This example illustrates the importance of base rates, which are the prior frequencies of events. An explanation can make an observation very likely without being the most likely explanation overall if the explanation itself is extremely rare.
Ignoring base rates leads to faulty reasoning. People may focus on whether an observation is typical under a hypothesis while failing to consider how common the hypothesis was before the observation occurred.
Bayesian reasoning does not mean that a small probability should be ignored. A serious but unlikely possibility may still justify further testing or caution. It means that the belief should reflect both the evidence and the prior probability.
Think About It
Why is “the symptom is common when the disease is present” not enough to conclude that the disease is likely? The disease’s prior probability and the symptom’s frequency among people without the disease also matter.
Independence
Two random variables X and Y are independent when learning the value of one does not change beliefs about the other.
The mathematical definition is:
P(X,Y)=P(X)P(Y)The joint distribution factors into two separate distributions.
Using the product rule:
P(X,Y)=P(X∣Y)P(Y)Combining this with the independence equation gives:
P(X∣Y)P(Y)=P(X)P(Y)After canceling P(Y), the equivalent condition is:
P(X∣Y)=P(X)Thus, independence means that observing Y does not change the probability assigned to X.
Example: Two Die Rolls
For two independent rolls of a fair die:
P(roll1=5)=61and
P(roll2=3)=61The probability of both events is:
P(roll1=5,roll2=3)=61⋅61=361If the first roll happens to be 4, the probability of a 3 on the second roll remains:
P(roll2=3)=61The first roll provides no information about the second.
Why Independence Is Powerful
If n coin flips are independent, the full joint distribution would contain 2n possible sequences. However, it is unnecessary to list every sequence. The model can simply specify the distribution of one flip and state that the flips are independent.
Independence therefore provides a compact representation of a large joint distribution. It can reduce the amount of information needed to describe a model exponentially.
In practice, however, complete independence is uncommon. Many real-world variables influence one another directly or indirectly.
Conditional Independence
Conditional independence occurs when two variables become independent after a third variable is known.
Consider three variables:
- Traffic
- Rain
- Umbrella use
No pair is necessarily independent:
- Observing an umbrella may increase the belief that it is raining.
- Observing rain may change the belief about traffic.
- Observing an umbrella may indirectly provide information about traffic because rain is related to both.
However, traffic and umbrella use may be conditionally independent given rain. Once the weather condition is already known, learning that a person has an umbrella may provide no additional information about traffic.
This can be written conceptually as:
P(traffic∣rain,umbrella)=P(traffic∣rain)The umbrella observation becomes irrelevant to traffic once rain has been established as the relevant connecting condition.
Conditional independence is more common and more useful than complete independence. It allows a complicated joint distribution to be factored into smaller local distributions while preserving important relationships.
This idea is the foundation of Bayes’ nets. Bayes’ nets represent variables and their conditional relationships in a structured graph, making probabilistic inference more tractable than direct manipulation of a massive joint table.
Comprehensive Review
Probability is a framework for representing uncertainty in situations involving incomplete information, noisy observations, limited computation, and uncertain outcomes.
The core ideas fit together as follows:
- A set of possible worlds, Ω, lists the complete possibilities being considered.
- A probability model assigns a nonnegative number to each possible world, with all probabilities summing to 1.
- An event is a set of possible worlds.
- The probability of an event is found by summing the probabilities of its worlds.
- A random variable is a function from possible worlds to values.
- A probability distribution gives the probabilities of the values of a random variable.
- A joint distribution describes several variables together.
- Marginalization sums out variables that are not relevant to a query.
- Conditional probability restricts attention to worlds consistent with known evidence.
- Normalization ensures that a conditional distribution sums to $1.
- The product rule expresses a joint probability as a conditional probability multiplied by a prior probability.
- The chain rule expands a joint distribution into a product of conditional distributions.
- Inference by enumeration selects evidence-consistent worlds, sums out hidden variables, and normalizes.
- Bayes’ rule reverses the direction of conditioning and combines prior beliefs with evidence.
- Independence allows a joint distribution to factor into separate distributions.
- Conditional independence allows variables to become independent once relevant information is known.
The most important conceptual lesson is that evidence changes beliefs by changing which possible worlds remain plausible and how probability mass is distributed among them. Bayes’ rule, marginalization, normalization, independence, and conditional independence are different tools for carrying out that same basic task: reasoning coherently about uncertain worlds.

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