8 - Probability and Uncertainty"
The real world is an uncertain place. In classical, deterministic planning, we often assume that an agent operates in an environment where it knows exactly what the state of the world is and what the outcomes of its actions will be. However, in realistic scenarios, an agent must make decisions based on incomplete or noisy information. This chapter introduces the foundations of probabilistic reasoning, providing the mathematical framework necessary to represent, quantify, and manage uncertainty in artificial intelligence.
1. The Nature of Uncertainty
Why is the real world uncertain? The uncertainty an intelligent agent faces stems from several fundamental sources:
- Partial Observability: The agent cannot see the entire state of the world. For example, a driver experiences the "fog of war" in traffic, a poker player cannot see their opponents' hands, and a doctor cannot see directly inside a patient's body.
- Noisy Sensors: Even what the agent can observe is subject to error. GPS systems have margin of error, cameras are unreliable in low light, and sonar readings can be distorted.
- Uncertain Action Outcomes: An agent's actions may not always succeed as intended. A car might suffer a flat tire or experience wheel slip; an object a robot attempts to lift might be too heavy.
- Unexpected Events: Unforeseen occurrences—such as a sudden car accident, an earthquake, or a meteor strike—can abruptly change the state of the world.
- Inherent Stochasticity: At a fundamental physical level (e.g., quantum mechanics), the universe contains inherent randomness that can affect both sensors and actuators.
- Complexity of Modeling: Predicting complex systems, like the stock market or city-wide traffic patterns, is exceptionally difficult because it involves the behavior of countless other agents and unexpected events.
To solve problems and make rational decisions in such an environment, we need a robust way to represent and quantify this uncertainty.
1.1 The General Probabilistic Situation
In a typical probabilistic scenario, the world consists of various variables. We can categorize them based on the agent's knowledge:
- Observed Variables (Evidence): The variables whose values the agent currently knows. These are often derived from sensor readings or observed symptoms.
- Unobserved Variables: The variables the agent needs to reason about but cannot directly see, such as the exact location of a hidden object or the specific disease a patient has contracted.
- Model: The knowledge the agent possesses about how the known (evidence) variables relate to the unknown variables.
Probabilistic reasoning provides a formal framework for managing the agent's beliefs given its model and the evidence it has collected.
1.2 The Failure of Pure Logic
Consider the action : "leave for the airport minutes before the flight." We want to evaluate the statement, "Will get me there on time?"
If we try to evaluate this using pure TRUE/FALSE propositional logic, we run into severe limitations. We cannot realistically list every possible condition that might affect the outcome, nor can we deduce the absolute truth value for sure.
If we make a strict assertion, such as "Leaving 25 minutes early will get me there on time," we risk falsehood—a traffic jam or flat tire would invalidate the statement. Conversely, if we try to make a mathematically sound logical statement, we end up with something too weak or overly complex for practical decision-making: "Leaving 25 minutes early will get me there on time if there is no accident on the bridge, and it doesn't rain, and my tires remain intact..." (This is known as the qualification problem). We might logically state, "Leaving 1440 minutes (24 hours) early will get me there on time," but this leads to highly undesirable behavior, such as camping overnight at the airport.
Instead of making absolute logical assertions, we use probability to summarize uncertainty. Probabilities represent the degree of belief an agent has that a given statement is true.
Crucially, this probability changes as the agent receives new information (evidence). If the agent learns it is 5:00 AM, the roads are likely clearer:
In this context, probability statements are not absolute assertions about the universe, but rather assertions about the knowledge state of the agent.
1.3 Decision Making Under Uncertainty
Once we can quantify uncertainty, how do we make decisions? Suppose you must choose an action based on the following probabilities of catching your flight:
The best choice depends on your personal preferences regarding the risk of missing the flight versus the annoyance of spending hours waiting in the terminal. These preferences are formalized using Utility Theory.
A utility function maps a state (or an outcome) to a real number, representing its desirability. For instance, the utility of waiting minutes might be modeled as .
Combining probability theory (what is likely to happen) with utility theory (what we want to happen) yields Decision Theory:
By maximizing expected utility, an agent can make optimal, rational decisions even when the outcomes are uncertain.
2. Fundamentals of Probability
2.1 Random Variables and Sample Spaces
A random variable represents some aspect of the world about which the agent is uncertain. We typically denote random variables with capitalized letters.
Examples:
- : Does the patient have a tooth cavity?
- : What is the weather like today?
- : How long will it take to drive to the airport?
- : The result of a dice roll.
Every random variable has a domain, which is the set of all its possible values (similar to the domain of a variable in Constraint Satisfaction Problems). The domain of a random variable is also referred to as the sample space, often denoted by .
- Domain of :
- Domain of :
- Domain of :
- Domain of :
Values of random variables are typically written in lowercase letters (e.g., , ).
2.2 Atomic Events and Probability Models
Let the set be the sample space (e.g., the 6 possible rolls of a die). Let be a sample point, also known as an atomic event or a possible world (e.g., a roll of 3).
A probability space (or probability model) pairs the sample space with an assignment for every possible world . If all elements are uniquely named, we often use the shorthand instead of .
An event is simply any subset of the sample space . The probability of an event is the sum of the probabilities of all atomic events it contains:
For example, the event of "rolling a 3 or a 6" has a probability equal to . The event space, denoted , is the power set of (the set of all possible events/subsets).
A simple intuitive notion of probability is the fraction of all possible worlds where the event is true, weighted by the likelihood of those worlds.
2.3 The Axioms of Probability
All of probability theory rests on three fundamental axioms formulated by Andrey Kolmogorov:
- Non-negativity: The probability of any event is a non-negative real number.
- Certainty of the Sample Space: The probability of the entire sample space is exactly 1.
- Additivity of Mutually Exclusive Events: If a sequence of events are mutually exclusive (i.e., they are disjoint sets, meaning no two events can happen simultaneously), the probability of their union is the sum of their individual probabilities.
From these three axioms, several important theorems immediately follow:
- Sum of all worlds: The sum of probabilities of all atomic events in the sample space is exactly 1.
- Boundedness: Every probability falls within the closed interval [0, 1].
- Subsets: If event A implies event B (i.e., ), then .
- Empty Set: The probability of the impossible event (the empty set ) is 0. .
- Complement: The probability of an event not happening is 1 minus the probability of it happening. .
- Inclusion-Exclusion Principle: For any two events A and B, the probability of A OR B is the sum of their individual probabilities minus the probability of their intersection. .
3. Probability Distributions
3.1 Prior Probability Distributions
A prior probability (or unconditional probability) reflects an agent's belief about a variable prior to the arrival of any new evidence.
We can define a probability distribution by associating a probability with every possible value in a random variable's domain. For a discrete variable, this is often represented as a table, where the values must sum up to 1.
| Weather (W) | Probability |
|---|---|
| sun | 0.6 |
| rain | 0.1 |
| fog | 0.3 |
| meteor | 0.0 |
| Temperature (T) | Probability |
|---|---|
| hot | 0.5 |
| cold | 0.5 |
3.2 Continuous Variables
Probability distributions are not limited to discrete variables. For continuous variables (like temperature in degrees, or time in seconds), we express the distribution using a parameterized function known as a Probability Density Function (PDF), denoted as . The total area under the PDF curve must integrate to 1.
Examples include the Uniform density function: (A uniform distribution between 18 and 26)
And the Gaussian (Normal) density function: Where is the mean and is the variance.
3.3 Joint Probability Distributions
A joint probability distribution over a set of random variables specifies a probability for every possible combination of assignments (every atomic event) to those variables.
For variables (Temperature) and (Weather):
| T | W | Probability |
|---|---|---|
| hot | sun | 0.4 |
| hot | rain | 0.1 |
| cold | sun | 0.2 |
| cold | rain | 0.3 |
A full joint distribution is incredibly powerful: every question about a domain can be answered by the joint distribution because every event is simply a sum of sample points (rows in the table).
However, the joint distribution suffers from the curse of dimensionality. For boolean variables, the joint distribution table requires entries. For variables each with domain size , the size of the table is . For all but the smallest, most trivial domains, it is entirely impractical to write out or store the full joint distribution.
3.4 Marginal Distributions
We can extract the distribution of a single variable (or a smaller subset of variables) from a joint distribution through a process called marginalization (or summing out).
To find the marginal distribution of a variable, we collapse the rows of the joint distribution by summing the probabilities of all combinations where that variable takes a specific value.
For example, to find from :
4. Conditional Probability
Conditional probability (or posterior probability) represents an agent's degree of belief after new evidence has been observed.
For example, means "given that toothache is all I know, the probability of a cavity is 0.8." It is crucial to understand that this does not mean "if a toothache is present, there is unconditionally an 80% chance of a cavity." It is strictly an assessment based on current evidence.
If new, overriding evidence arrives, the probability may change to reflect certainty:
Conversely, new evidence may be completely irrelevant to the query, allowing us to simplify our expressions: This ability to ignore irrelevant information, sanctioned by domain knowledge, is crucial for efficient inference.
4.1 Definition of Conditional Probability
Mathematically, the conditional probability of event given event (where ) is defined as:
This represents the probability of both and occurring, divided by the probability of the evidence occurring.
4.2 Conditional Distributions
Just as we have joint distributions, we can have conditional distributions: probability distributions over some variables given fixed values of other evidence variables.
Given the joint distribution , we might want the conditional distribution :
4.3 The Normalization Trick
A common and highly practical way to compute conditional distributions from a joint distribution is the Normalization Trick. It avoids having to separately calculate the marginal probability used in the denominator.
Suppose we want to find the distribution :
- Select: Identify all rows in the joint distribution that match the evidence ().
- (cold, sun) 0.2
- (cold, rain) 0.3
- Normalize: Sum the selected probabilities to find a normalization constant (here, ). Divide each selected probability by this constant so the new values sum to 1.
This works mathematically because the sum of the selected probabilities is exactly the probability of the evidence, . We often denote this normalization constant as , allowing us to write:
5. Rules of Probability and Inference
5.1 The Product Rule and Chain Rule
By rearranging the definition of conditional probability, we obtain the Product Rule, which allows us to compute joint probabilities from conditional ones:
The Product Rule can be applied sequentially to express any full joint distribution as an incremental product of conditional distributions. This is known as the Chain Rule:
5.2 Bayes' Rule
Because the joint probability can be written in two ways using the Product Rule:
We can divide by to obtain Bayes' Rule (or Bayes' Theorem):
Bayes' Rule is arguably the most important formula in AI and machine learning. It is useful because it allows us to build one conditional probability from its reverse. Very often in real-world modeling, one direction is easy to estimate (e.g., the causal probability that a disease causes a symptom), while the reverse direction is exactly what we want to query (the diagnostic probability of the disease given the symptom).
Example: Inference with Bayes' Rule Let be meningitis and be a stiff neck.
- Prior probability of meningitis:
- Prior probability of a stiff neck:
- Causal probability (if you have meningitis, probability of stiff neck):
We want the diagnostic probability: If a patient has a stiff neck, what is the probability they have meningitis?
Note that the posterior probability of meningitis is still very small because the prior probability of the disease is extremely low compared to the prior probability of getting a stiff neck.
5.3 Inference by Enumeration
Probabilistic Inference is the task of using a probabilistic model and evidence to reason about specific query variables.
We formally define the sets of variables:
- : All random variables in the domain .
- : Evidence variables whose values are observed as .
- : The Query variable (for simplicity, we assume a single query variable, though the method scales to multiple).
- : Hidden variables, which are all variables in that are neither evidence nor query variables.
The goal of inference is to compute the conditional distribution .
The most direct algorithm is Inference by Enumeration:
- Select: Take the full joint distribution and select all entries (rows) that are consistent with the observed evidence .
- Marginalize: Sum out all the Hidden variables to obtain the joint distribution of just the Query and the Evidence: .
- Normalize: Divide the resulting table by the sum of its entries (which is ) to yield the conditional distribution .
Mathematically, this looks like: Where the sum over iterates through all possible combinations of assignments to the hidden variables .
The Problem with Enumeration While theoretically sound, Inference by Enumeration is completely intractable for real-world problems.
- Worst-case Time Complexity: where is the domain size and is the total number of variables.
- Worst-case Space Complexity: just to store the joint probability distribution table in memory.
To handle non-trivial domains, we must find a way to reduce the size of the joint distribution representation.
6. Independence and Conditional Independence
To defeat the exponential blowup of the joint distribution, we utilize structural properties of the domain: specifically, independence.
6.1 Absolute Independence
Two variables and are independent if the occurrence of one does not affect the probability of the other. Mathematically, this is true if and only if:
Equivalently, this implies:
Independence is extremely powerful. If we have independent fair coin flips, instead of a joint distribution requiring entries, we can represent it entirely with individual distributions, reducing the complexity to .
Unfortunately, absolute independence is very rare in the real world. In a domain like dentistry, hundreds of variables (diet, genetics, brushing habits, cavities, toothaches) interact, and very few are strictly independent of one another. Assuming absolute independence where it doesn't exist leads to highly inaccurate models.
6.2 Conditional Independence
While absolute independence is rare, conditional independence is our most basic and robust tool for organizing knowledge about uncertain environments.
Two variables and are conditionally independent given a third variable if and only if:
Equivalently:
Example: Dentistry Consider the variables Toothache, Cavity, and Catch (whether a dentist's steel probe catches in the tooth). Are Toothache and Catch absolutely independent? No. If the probe catches, it's more likely you have a cavity, which makes it more likely you have a toothache.
However, if you already know the patient has a cavity (), then knowing they have a toothache provides no additional information about whether the probe will catch. The physical state of the tooth (the cavity) completely separates the two symptoms. Therefore, Catch is conditionally independent of Toothache given Cavity:
Using the Chain Rule, we can rewrite the joint distribution:
By exploiting this conditional independence, we factored a joint distribution requiring independent numbers into three smaller tables requiring independent numbers. In large systems, the use of conditional independence can reduce the size of the representation from exponential to linear .
6.3 The Naïve Bayes Model
A common and highly practical application of conditional independence is the Naïve Bayes Model. It assumes that all "effects" (symptoms, features) are conditionally independent of each other given the "cause" (the disease, the class).
Under this assumption, the total number of parameters required to define the joint distribution scales linearly with the number of effects , making it exceptionally fast and efficient for many real-world classification tasks, even if the assumption of perfect conditional independence is slightly "naïve."
Summary
- Probability provides a mathematically rigorous formalism for managing uncertain knowledge and beliefs.
- The Joint Probability Distribution specifies the probability of every possible atomic event in a domain.
- Inference queries can theoretically be answered by summing (marginalizing) over atomic events consistent with observed evidence, then applying Bayes' Rule or the Normalization Trick.
- Because the full joint distribution grows exponentially, we must exploit Conditional Independence to factor the joint distribution into smaller, manageable conditional probability tables. This makes realistic inference algorithms mathematically tractable.