Inferensys

Glossary

Factor Graph

A factor graph is a bipartite graphical model that represents the factorization of a probability distribution, commonly used in robotics for Simultaneous Localization and Mapping (SLAM) and state estimation.
ML engineer managing model training cluster on laptop, GPU utilization visible, technical deep learning setup.
FLEET STATE ESTIMATION

What is a Factor Graph?

A factor graph is a probabilistic graphical model that provides a unified framework for representing and solving complex state estimation problems, such as those found in Simultaneous Localization and Mapping (SLAM) for autonomous fleets.

A factor graph is a bipartite graphical model that explicitly represents the factorization of a global probability distribution into a product of simpler, local functions called factors. In robotics and fleet state estimation, these factors encode probabilistic constraints derived from sensor measurements (like LiDAR or camera data), motion models (from odometry), and prior knowledge, connecting to variable nodes that represent unknown system states, such as robot poses and landmark positions. This graphical structure directly exposes the sparse dependencies inherent in estimation problems, enabling highly efficient inference algorithms.

The primary computational advantage of a factor graph is its use with non-linear optimization techniques, most notably Gauss-Newton or Levenberg-Marquardt algorithms, which solve for the most probable configuration of all variables by iteratively linearizing the factors. This approach, central to modern graph-based SLAM, efficiently performs batch optimization to correct for accumulated odometric drift when a loop closure is detected. By representing the entire history of poses and measurements, factor graphs provide a scalable and flexible backbone for maintaining a consistent, real-time world model across a heterogeneous fleet.

GRAPHICAL MODEL

Key Components of a Factor Graph

A factor graph decomposes a complex probability distribution into a product of simpler local functions. Its bipartite structure explicitly separates the variables representing unknown states from the factors encoding probabilistic constraints.

01

Variable Nodes

Variable nodes represent the unknown random variables whose joint distribution the graph models. In robotics and state estimation, these typically correspond to quantities like:

  • Robot poses at different timestamps (e.g., x, y, yaw).
  • Landmark positions in a map (e.g., 3D coordinates).
  • Sensor calibration parameters (e.g., camera intrinsics). Each node is connected to the factors that depend on it. The primary inference goal is to estimate the marginal or joint distribution over these variables.
02

Factor Nodes

Factor nodes represent the local functions, or factors, that encode probabilistic constraints and relationships between the connected variable nodes. Each factor is a non-negative function proportional to a conditional probability. Common examples in SLAM include:

  • Motion factors (from odometry or an IMU) that connect consecutive robot poses.
  • Observation factors (from cameras or LiDAR) that connect a robot pose to an observed landmark.
  • Loop closure factors that impose a constraint between non-consecutive poses when a previously visited location is recognized.
  • Prior factors that anchor the graph with an initial belief.
03

Edges (Connections)

Edges in a factor graph are undirected connections that exist only between a factor node and a variable node. This strict bipartite property is fundamental. An edge indicates that the connected variable is an argument to that factor's function. For example:

  • A binary factor connecting two variable nodes (e.g., a motion factor between pose X_t and pose X_{t+1}).
  • A unary factor connecting to a single variable (e.g., a prior on the first pose).
  • A higher-order factor connecting to three or more variables (e.g., a visual reprojection error factor connecting a camera pose and a 3D landmark point to a 2D image measurement).
04

The Global Function

The entire factor graph represents the factorization of a global function. In probabilistic inference, this is the joint probability distribution over all variables, expressed as a product of the local factors. Formally, for variables X and factors f_k, the joint distribution is: P(X) ∝ ∏_{k} f_k ( X_k ) where X_k is the subset of variables connected to factor f_k. This factorization turns the complex problem of estimating the full joint distribution into a more manageable problem of defining and optimizing over local relationships. The sparsity of the graph (each factor connects only to a few variables) is what enables efficient computation.

05

Inference Algorithms

Solving a factor graph means performing probabilistic inference to estimate the variables. This is not a structural component but the computational process applied to the graph. Key algorithms include:

  • Belief Propagation (BP) / Sum-Product Algorithm: Passes messages along edges to compute marginal distributions.
  • Gaussian Belief Propagation: A specialized, highly efficient version for graphs where all factors are Gaussian, common in SLAM.
  • Non-linear Optimization: For maximum a posteriori (MAP) estimation, the problem is often framed as minimizing the sum of negative log-likelihoods from each factor, leading to a non-linear least squares problem solvable via Gauss-Newton or Levenberg-Marquardt methods. Libraries like g2o and GTSAM implement this optimization over factor graphs.
06

Comparison to Related Graphs

Factor graphs generalize and clarify other graphical models used in robotics.

  • Vs. Bayes Nets: A Bayesian network is a directed, acyclic graph representing conditional dependencies. Any Bayes net can be converted to a factor graph, but factor graphs are more explicit about the factorization.
  • Vs. Markov Random Fields (MRFs): MRFs are undirected graphs where edges represent mutual influence. A factor graph can represent the same distribution, with each clique in the MRF becoming a factor node connected to all variables in that clique.
  • Vs. Pose Graphs: A pose graph is a specific, simplified type of factor graph used in SLAM where variable nodes are only robot poses, and factors represent constraints between them (e.g., from odometry or loop closures). Landmarks, if present, are typically marginalized out.
GRAPHICAL MODEL COMPARISON

Factor Graph vs. Pose Graph

A technical comparison of two graphical models used for state estimation in robotics and SLAM, highlighting their structural differences and primary applications.

FeatureFactor GraphPose Graph

Graphical Model Type

Bipartite graph

Unary/Binary graph

Primary Node Types

Variable nodes, Factor nodes

Pose nodes (variables only)

Edge Representation

Connects factor to its variables

Connects two pose nodes

Encoded Information

Full joint probability factorization

Spatial constraints between poses

Typical Constraints

Odometry, loop closure, landmark observations

Odometry, loop closure

Landmark Representation

Explicit variable nodes

Implicitly marginalized out

Optimization Target

Posterior over all variables (poses + landmarks)

Posterior over robot poses only

Sparsity Pattern

Dense connections from factors to variables

Sparse connections between poses

Common Solver

Gauss-Newton, Levenberg-Marquardt on full system

Pose graph optimization (often same solvers)

Memory/Compute Scaling

Larger (includes landmarks)

More compact (poses only)

Primary Use Case

Full SLAM (mapping + localization)

Pose graph SLAM (trajectory optimization after landmark marginalization)

FACTOR GRAPH

Frequently Asked Questions

Factor graphs are a core mathematical framework for probabilistic state estimation in robotics and autonomous systems. These FAQs address their fundamental role in solving Simultaneous Localization and Mapping (SLAM) and related problems for heterogeneous fleet orchestration.

A factor graph is a bipartite graphical model that represents the factorization of a global probability distribution into a product of simpler, local functions, or factors. It provides a visual and computational framework for structuring inference problems, most notably in Simultaneous Localization and Mapping (SLAM) and sensor fusion. The graph consists of two types of nodes: variable nodes (representing unknown states like robot poses or landmark positions) and factor nodes (representing probabilistic constraints between those variables, derived from sensor measurements or motion models). By encoding the problem in this sparse graph, efficient inference algorithms can compute the most probable configuration of all variables.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.