Probability and Uncertainty in AI
Probability and Probabilistic Reasoning
Uncertainty and probabilistic models
Many real-world problems cannot be described by a complete, deterministic model. Some factors are outside an agent’s control, some cannot be observed, and some are too complex to compute in detail. These limitations create uncertainty about what has happened or what will happen.
Probabilistic reasoning provides a formal way to represent and reason about uncertainty. It combines:
A model of how relevant aspects of the world relate to one another.
Evidence: values that have been observed or are otherwise known.
Computations that update beliefs about unknown quantities in light of the model and evidence.
A probabilistic model can support decisions such as identifying the most likely location of an object or estimating the expected utility of taking an action. In artificial intelligence, probabilistic reasoning is often paired with machine learning: the model represents relationships among variables, while learning methods can estimate the model’s parameters from data or experience.
Earlier rule-based approaches to artificial intelligence could work well for domains whose rules were sufficiently clear, such as some games. But rule-based systems struggled to scale to many real-world settings, where information is incomplete or noisy. Probabilistic methods provide a framework for handling that uncertainty.
A running example: locating a ghost
Suppose a ghost is hidden somewhere on a board. Its location is unknown, and the goal is to choose where to attempt to catch it. A sensor can be placed at a location and returns a color that provides information about how close the ghost may be. Red might suggest that the ghost is nearby, while green might suggest that it is far away.
The sensor is noisy: the same distance can produce different colors, and the same color can result from different distances. The reading therefore does not reveal the ghost’s location with certainty.
This problem has three essential parts:
Unknown quantity: the ghost’s location.
Evidence: the sensor readings already collected.
Sensor model: probabilities describing how likely each reading is at each distance from the ghost.
Before any readings are collected, a model might assign equal probability to every location. This is the prior distribution. After readings arrive, the probability of each location can change. The resulting distribution is the posterior distribution: the belief about the ghost’s location given the evidence.
The same structure appears in other applications. In medical diagnosis, a disease may be unknown while symptoms and test results are observed. In spam detection, the message category is unknown while the words in the message are evidence.
Probabilistic inference combines a model with evidence to compute updated probabilities for quantities of interest.
Random variables
A random variable represents an aspect of the world that matters to a model. A variable may describe something observed, something to infer, or something that helps express how the world works.
Examples include:
R: whether it is raining.
T: whether the temperature is hot or cold.
D: the time required to drive to work.
L: the ghost’s location.
A sensor variable: the color returned by a probe.
A random variable has a domain, the set of values it can take. For example:
R may have domain {true,false}.
T may have domain {hot,cold}.
A weather variable may have domain {sun,rain,fog}.
A travel-time variable may take real-valued outcomes.
A location variable may take values from a set of board positions.
Variables with true-or-false domains are Boolean. Variables can also be discrete without being Boolean, or continuous. The probability concepts apply to both discrete and continuous variables, though continuous cases generally require integrals rather than sums.
Notation
Variables are conventionally written with capital letters, while their values are written in lowercase. Thus, R names a variable and r can name one of its values.
For Boolean variables, a compact notation is often useful:
+R means that R is true.
−R means that R is false.
A variable may be observed, meaning its value is known, or unobserved, meaning its value is not known. An observed value becomes evidence for inference.
Probability distributions
A probability distribution assigns a probability to each possible value of a variable. For a discrete variable X, the distribution P(X) contains one probability for every value in the domain of X.
For example, a distribution over weather could assign:
P(sun)=0.6
P(rain)=0.1
P(fog)=0.3
A distribution over X is different from the probability of one particular value of X:
P(X) refers to the whole distribution over X.
P(X=x) refers to the single probability that X has value x.
A legal discrete probability distribution must satisfy two rules:
Every probability is nonnegative.
The probabilities across all values sum to 1.
In practice, assigning a probability of exactly 0 to an outcome can be risky. A zero says the outcome is impossible under the model, regardless of what evidence arrives. If an outcome is merely very unlikely, it is usually safer to assign it a small positive probability. A true zero should generally be reserved for outcomes that really are impossible.
For continuous variables, probability is described using a density rather than a list of probabilities for individual values. The corresponding normalization condition uses an integral instead of a sum.
Joint distributions and probabilistic models
A joint distribution assigns a probability to every complete assignment of values to a set of variables. A complete assignment specifies a value for each variable.
For example, let T represent temperature, with values hot or cold, and let W represent weather, with values sun or rain. Their joint distribution contains probabilities for all four possible combinations:
hot and sun
hot and rain
cold and sun
cold and rain
The notation P(T,W) denotes the whole joint distribution. A particular entry, such as P(T=hot,W=sun), is one number in that distribution.
A joint distribution contains information about:
How likely each complete outcome is.
How the variables relate to one another.
Which combinations of values are common or rare.
A probabilistic model can be understood as a joint distribution over the model’s variables. Unlike a constraint satisfaction problem, which indicates whether an assignment is permitted or forbidden, a probabilistic model assigns degrees of likelihood to outcomes. An outcome with low probability is unlikely under the model, but it need not be impossible.
Why joint distributions become too large
Suppose there are N variables and each has D possible values. A complete assignment chooses one value for each variable, so a full joint distribution has DN entries.
For Boolean variables, this becomes 2N. The number of entries therefore grows exponentially with the number of variables. A full joint table quickly becomes too large to store or compute with directly, even though it contains enough information to answer any probability question about the modeled variables.
This creates a central challenge:
A full joint distribution is expressive and, in principle, sufficient for answering queries.
It is generally impractical to construct, store, or process in full for a large model.
Efficient probabilistic methods exploit structure among variables so that they can work with compact components instead of enumerating every complete assignment.
Outcomes, events, and consistency
An outcome is a complete assignment to all variables in a model. An event is a set of outcomes.
For example, the event “it is hot” includes every complete outcome whose temperature value is hot, regardless of the weather value. The probability of an event is the sum of the probabilities of all outcomes in that event.
For a partial assignment such as T=hot, a complete assignment is consistent with the partial assignment if it gives T the value hot. Its other variable values can vary.
This provides a general way to compute event probabilities from a joint distribution:
Identify all complete assignments that match the event.
Add their probabilities.
For example, if the hot-and-sunny outcome has probability 0.4 and the hot-and-rainy outcome has probability 0.1, then
The probability of a specific complete outcome may already appear as a single entry in the joint distribution. The probability of a broader event usually requires adding multiple entries.
Marginal distributions
A marginal distribution is a distribution over a subset of the variables in a joint distribution, obtained by removing the other variables. Removing a variable requires combining probabilities for outcomes that differ only in the value of that variable.
This operation is called marginalization, or summing out.
For example, to obtain the distribution over temperature from the joint distribution over temperature and weather, the weather variable is summed out:
Thus, the probability of hot is found by adding the probabilities of hot-and-sun and hot-and-rain. The probability of cold is found in the same way by adding the cold outcomes.
The marginal distribution over weather is obtained by summing out temperature:
Marginalization is a basic way to derive a simpler distribution from a larger one. It is also a central step in inference when a model contains variables that are not part of the desired answer.
Conditional probabilities
A conditional probability describes the probability of an event A given that another event B is known to have occurred. It is defined by
provided P(B)>0.
The numerator, P(A,B), is the probability that both events occur. The denominator, P(B), is the total probability of the known conditioning event. The ratio therefore measures what fraction of the probability mass for B also satisfies A.
For example, the probability that it is sunny given that it is cold is
If the joint probability of cold and sun is 0.2, and the total probability of cold is 0.5, then the conditional probability is 0.4.
The denominator is obtained by adding all outcomes consistent with the conditioning event. In this example, cold includes both cold-and-sun and cold-and-rain.
Conditional distributions and normalization
A conditional distribution gives a probability for each possible value of a query variable, given specified evidence. For example, P(W∣T=hot) is a distribution over all weather values under the condition that the temperature is hot.
Each entry is a conditional probability. For example,
A conditional distribution is still a probability distribution: its entries are nonnegative and sum to 1. It differs from a marginal distribution because it incorporates evidence. The marginal P(W) describes weather without conditioning on temperature; P(W∣T=hot) describes weather given the specified temperature.
Select and normalize
A practical method for computing a conditional distribution from a joint distribution is:
Select the entries consistent with the evidence.
Normalize the selected entries so that they sum to 1.
For example, to compute P(X∣Y=−) from a joint table over X and Y, retain only the rows in which Y is false. The remaining entries may not sum to 1, because entries for the other value of Y have been removed. Divide each remaining entry by their total.
If the selected entries are 0.3 and 0.1, their total is 0.4. Normalizing gives
and
The normalized values form a distribution over X given the evidence Y=−.
Normalization preserves the relative proportions of the selected entries while making their total equal to 1. When every possible value of the query variable is included, the normalization denominator is the total probability of the evidence.
Probabilistic inference and belief updating
Probabilistic inference is the computation of a desired probability from probabilities already represented in a model. The desired quantity is often a conditional distribution over one or more query variables given observed evidence.
A probabilistic inference problem separates variables into three groups:
Evidence variables: variables whose values are known.
Query variables: variables whose probabilities are being requested.
Hidden variables: variables that are not observed and are not part of the requested answer.
For example, in the ghost-location problem:
The readings already collected are evidence.
The ghost’s location is the query.
Other unobserved quantities, such as readings that could have been taken at other locations, may be hidden variables.
A rational agent’s beliefs can be represented by conditional probabilities given its evidence. When new evidence arrives, those probabilities may change. For instance, the probability that a trip will be on time may increase when no accidents are reported and decrease when it is raining.
The model encodes how variables relate; evidence determines which parts of that model are relevant to the current belief update.
Inference by enumeration
The most direct method for computing a query from a joint distribution is inference by enumeration. It operates on the full joint table and proceeds in three main steps:
Select evidence-consistent entries. Remove assignments that disagree with known evidence.
Sum out hidden variables. Combine entries that differ only in hidden-variable values.
Normalize. Make the remaining values form a probability distribution over the query variables.
Suppose the query variable is Q, the evidence assignment is e, and the hidden variables are represented by H. For each value of Q, the unnormalized result is obtained by summing the joint probabilities over all hidden-variable assignments consistent with the evidence:
The result is then normalized across the possible values of Q:
This method clarifies how inference works, but it is often computationally expensive. The joint table is already exponential in the number of variables, and enumeration may require processing many of its entries. As a result, inference by enumeration is mainly useful as a conceptual baseline or for small problems.
If an inference problem has no evidence, selecting does not remove any entries. If there are no hidden variables, no summing-out step is required. As variables become observed, they move into the evidence set; fewer values must be summed out, while more entries are removed by selection.
Why compact models are necessary
Direct inference by enumeration has several limitations:
Storage cost: the full joint distribution can require exponentially many entries.
Computation cost: computing a query may require summing over exponentially many assignments.
Learning cost: estimating every probability in a large table can require an impractically large amount of data, since many particular assignments may be rare.
The practical goal is therefore not to build the full joint table whenever possible. Instead, probabilistic models use structure to represent relationships compactly and support inference without enumerating every outcome. Graphical models are one such way to express which variables directly interact. In temporal settings, hidden Markov models are an example of a model designed for variables that evolve over time.
The product rule
The product rule relates a joint distribution to a marginal distribution and a conditional distribution:
It follows directly from the definition of conditional probability. It provides a way to construct a joint probability from a probability for Y and a conditional probability for X given Y.
For example, suppose W describes weather and D describes whether the ground is wet or dry. If the probability of sun is P(W=sun)=0.8, and the probability of wet ground given sun is P(D=wet∣W=sun)=0.1, then
A conditional probability table may contain a separate distribution for each value of the conditioning variable. For example, it may provide a distribution over wet and dry given sun, and another distribution over wet and dry given rain. Each conditional distribution separately sums to 1; the combined collection is a family of distributions rather than one distribution that necessarily sums to 1 as a whole.
The chain rule
The chain rule extends the product rule to any number of variables. A joint distribution over X1,…,Xn can be written as
In words, the first variable is represented by its marginal distribution. Each later variable is represented by its conditional distribution given all variables that came before it in the chosen ordering.
For three variables, this becomes
The chain rule follows by repeatedly applying the product rule. Each new conditional probability contributes a joint probability divided by the probability of the variables already included; those intermediate terms cancel, leaving the full joint distribution.
The chain rule does not, by itself, guarantee a compact representation. In the general case, each variable may depend on all the preceding variables. Its importance is that it shows how conditional distributions can be combined to express a joint distribution. More efficient models take advantage of cases where each variable depends directly on only a smaller subset of the others.
Bayes’ rule
Bayes’ rule reverses the direction of a conditional probability:
It follows by writing the joint probability in two ways:
and
Setting these expressions equal and rearranging gives Bayes’ rule.
The rule is especially useful when the probability that is easy to model is not the probability that is needed. A model may describe how likely an effect is given a cause, P(effect∣cause), while an application needs the probability of the cause given the observed effect, P(cause∣effect).
Diagnostic reasoning example
Let M indicate meningitis and S indicate a stiff neck. A diagnostic question asks for
the probability of meningitis given a stiff neck. Available information may instead include:
The prior prevalence P(M).
The probability of a stiff neck among people with meningitis, P(S∣M).
The probability of a stiff neck among people without meningitis, P(S∣¬M).
Bayes’ rule uses these quantities to compute
The probability of a stiff neck in the denominator accounts for all ways the symptom can occur, including cases without meningitis. Consequently, a symptom may be strongly associated with a disease while the disease remains unlikely if its prior probability is very low.
Probability is not the same as utility
The most probable outcome is not necessarily the best basis for a decision. Probability describes how likely an outcome is; utility describes how valuable or costly that outcome is.
A symptom may imply only a small probability of a serious condition, yet seeking medical evaluation can still be sensible if the cost of failing to detect the condition would be very high. Similarly, in the ghost example, a sensing action may improve the estimate of the ghost’s location but consume points or time.
Decisions therefore may require both:
Probabilities, to represent uncertainty about outcomes.
Utilities, to represent the desirability or cost of outcomes and actions.
The trade-off between gaining information and paying for a sensing action is called a value-of-information question. Probabilistic inference supplies the beliefs needed for such decisions, but probability alone does not determine which action has the highest utility.
Using evidence to locate the ghost
In the ghost example, the prior distribution describes the ghost’s location before any sensor readings are observed. Each reading provides evidence whose likelihood depends on the ghost’s possible location and the sensor’s noise model.
After receiving a reading, inference selects the locations and sensor outcomes consistent with the observed evidence, accounts for uncertain variables, and normalizes the resulting probabilities. Repeating this process updates the posterior distribution after each new reading.
The posterior is not necessarily concentrated on one location. It can assign different probabilities to many locations, reflecting remaining uncertainty. A decision-maker can then use the full distribution—for example, by choosing the most likely location or by evaluating the expected utility of possible actions.
The essential pattern is that evidence changes beliefs through a probabilistic model, producing a posterior distribution over the quantity of interest.

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