A probabilistic graphical model (PGM) is a representation of a joint probability distribution over many random variables in which a graph states which variables depend on each other directly. Nodes stand for random variables and edges, or their absence, encode conditional independence assumptions, so that a large distribution factorizes into small local factors that are easier to specify, learn and compute with.
Within probabilistic models in artificial intelligence, graphical models provide the common language behind Bayesian networks, Markov random fields, hidden Markov models and conditional random fields. The framework unites three tasks: representation, inference and learning.
How a graph factorizes a probability distribution
A graphical model works by replacing one enormous table of joint probabilities with a product of local terms. For 30 binary variables a full joint table needs more than a billion entries; if each variable depends directly on at most three others, the factorized model needs only a few hundred parameters.
In a directed model, the joint distribution is the product of each variable’s probability given its parents, written P(x) = ∏ P(xᵢ | parents(xᵢ)). In an undirected model, it is a normalized product of nonnegative potential functions over cliques, divided by a partition function Z that makes the total sum to one. Computing Z is often the hardest part of working with undirected models.
The graph also supports reading independence directly from structure. In directed graphs the criterion is d-separation; in undirected graphs, two sets of variables are independent given a third set when every path between them passes through that set.
Main families of probabilistic graphical models
Probabilistic graphical models fall into directed, undirected and hybrid families, which differ in what kind of dependence they express naturally. The table compares the main members.
| Model family | Graph type | Natural for | Example application |
|---|---|---|---|
| Bayesian network | Directed acyclic graph | Causal or generative stories | Medical diagnosis |
| Markov random field | Undirected graph | Symmetric spatial interactions | Image denoising |
| Conditional random field | Undirected, conditioned on inputs | Structured prediction of labels | Named entity tagging |
| Factor graph | Bipartite variables and factors | Explicit factor structure for inference | Error-correcting decoders |
| Dynamic Bayesian network | Directed, unrolled over time | Sequential processes | Speech and tracking |
| Hidden Markov model | Directed chain with hidden states | Sequences with latent regimes | Gene finding |
Directed and undirected models are not equally expressive: some independence patterns can be drawn only as a directed graph, others only as an undirected one. Factor graphs are often used as a neutral intermediate form because both families convert into them without loss.
Inference in graphical models
Inference means computing probabilities of query variables given observed evidence, such as the posterior distribution of a hidden cause or the most probable joint assignment. Exact inference in general graphs is NP-hard, so the graph structure decides which algorithm is practical.
The key quantity for exact methods is the treewidth of the graph: cost grows exponentially in treewidth but only linearly in the number of variables. Chains and trees are cheap; dense grids are not. The table summarizes the standard options.
| Algorithm | Exact or approximate | Works best on | Main limitation |
|---|---|---|---|
| Variable elimination | Exact | Single queries, low treewidth | Order of elimination matters |
| Belief propagation | Exact on trees | Trees and chains | Only approximate on loopy graphs |
| Junction tree algorithm | Exact | Many queries, moderate treewidth | Clique size grows quickly |
| Gibbs sampling | Approximate | Large discrete models | Slow mixing with strong correlations |
| Variational inference | Approximate | Large continuous or latent models | Biased, often underestimates variance |
Familiar sequence algorithms are special cases of message passing: the forward-backward algorithm is belief propagation on a chain, and the Viterbi algorithm is its max-product version that returns the single most likely state sequence.
Learning structure and parameters
Learning a graphical model has two separate problems: parameter learning and structure learning. When the graph is fixed and all variables are observed, parameters of a Bayesian network follow from counting, through maximum likelihood estimation or a Bayesian estimate with a conjugate prior such as the Dirichlet distribution.
With hidden or missing variables, the likelihood no longer decomposes, and the standard tool is the expectation-maximization algorithm, which alternates between inferring hidden values and refitting parameters; Baum-Welch is its form for hidden Markov models. Structure learning searches over graphs with score-based methods such as BIC or constraint-based methods such as the PC algorithm, which runs conditional independence tests.
| Setting | Typical method | Practical difficulty |
|---|---|---|
| Known graph, complete data | Maximum likelihood or Bayesian counting | Sparse counts for rare combinations |
| Known graph, hidden variables | Expectation-maximization | Local optima, sensitive to initialization |
| Unknown graph | Score-based or constraint-based search | Search space grows superexponentially |
| Undirected models | Gradient methods, pseudo-likelihood | Partition function is costly |
Strengths, limitations and common misconceptions
The main strength of a PGM is interpretable, modular uncertainty: experts can inspect each local factor, combine domain knowledge with data and query any variable given any evidence. Graphical models also handle missing data naturally and remain useful when datasets are small.
- Arrows are not automatically causal: a Bayesian network learned from observational data encodes dependence, and causal claims require additional assumptions.
- Missing edges are strong claims: every absent edge asserts an independence that may be false in real data.
- Exact inference does not scale freely: high treewidth forces approximate methods with their own errors.
- Deep learning is not a replacement in every case: neural networks scale better on raw data, while graphical models offer structure and calibrated uncertainty; modern work combines both in deep generative models and probabilistic programming.
A non-technical view
A probabilistic graphical model is a map of how uncertain things influence each other. Each circle on the map is something unknown, such as an illness or a test result. Each line shows a direct influence.
The map saves work. You do not need to know how everything relates to everything else. You only describe each item and its close neighbors. When new facts arrive, the model updates its beliefs about the rest, much like a detective revising suspicions after each clue.
A concrete example
A team building decision support for a hospital emergency department models suspected pulmonary embolism with a Bayesian network of 25 variables: risk factors such as recent surgery and immobility, symptoms such as chest pain and heart rate above 100 beats per minute, and test results such as D-dimer and CT angiography. Clinicians draw the graph together with the data scientists, and conditional probability tables are estimated from about 12,000 past cases with Dirichlet priors.
Because the network has low treewidth, the junction tree algorithm returns exact posterior probabilities in milliseconds, even when several tests are still missing. For a patient with a negative D-dimer and few risk factors, the probability falls below the threshold set by the clinical team, and the system suggests that imaging can be deferred.
The outcome is a tool that explains its reasoning variable by variable, which clinicians accept more readily than an opaque score, and which reduced unnecessary CT scans in the pilot evaluation.