Transition function

Also known as: transition dynamics · state transition probability

On this page 7

A transition function is the component of a Markov decision process that specifies how the environment responds to an agent: for every current state and action, it gives the probability distribution over next states. In reinforcement learning it is usually written P(s′ | s, a) or T(s, a, s′), and it is also called the transition dynamics or the state transition probability.

Together with the reward function, the transition function defines the rules of the problem the agent must solve. It encodes cause and effect in the environment, and whether an algorithm knows it, learns it or ignores it is the dividing line between model-based and model-free methods.

How the transition function defines environment dynamics

Formally, the transition function maps a state-action pair to a distribution over the state space. For finite problems, each pair (s, a) yields a vector of probabilities that are non-negative and sum to exactly one. For continuous states, the function becomes a conditional probability density, and the sum turns into an integral.

The definition rests on the Markov property: the next state depends only on the current state and action, not on the earlier history. If the true process depends on hidden variables, the problem is better modeled as a partially observable Markov decision process, where the agent sees observations rather than states.

The table below shows a small stochastic transition function for a robot on a slippery floor, where an intended move succeeds only most of the time.

Current stateActionNext stateProbability
Cell (1,1)Move rightCell (1,2)0.8
Cell (1,1)Move rightCell (2,1)0.1
Cell (1,1)Move rightCell (1,1)0.1
Cell (1,2)Move upCell (2,2)1.0
Example transition probabilities on a slippery grid

Deterministic and stochastic transitions

A transition function is deterministic when each state-action pair leads to exactly one next state with probability one, as in chess or most puzzles. It is stochastic when outcomes vary, as in dice games, physical robots with sensor noise or markets driven by other actors.

FormNotationTypical environment
Deterministics′ = f(s, a)Board games, symbolic puzzles
Stochastic, discreteP(s′ | s, a) as a tableGrid worlds, inventory problems
Stochastic, continuousDensity p(s′ | s, a)Robotics, physical control
Joint with rewardp(s′, r | s, a)General textbook formulation
Non-stationaryP changes over timeMarkets, opponents that adapt
Main forms of transition functions

Many textbooks use the joint dynamics function p(s′, r | s, a), which gives the probability of the next state and reward together. The plain transition function is obtained by summing out the reward, and the expected reward is obtained by summing out the next state.

The role of the transition function in the Bellman equation

The transition function appears inside every Bellman equation, because the value of an action equals its immediate reward plus the discounted expected value of whatever state follows. That expectation is computed by weighting each possible next state by its transition probability.

Dynamic programming methods such as value iteration and policy iteration require the full transition function, since they sweep over all states and compute these expectations exactly. Their cost grows with the number of states times actions times successor states, which is why exact planning works only for modest state spaces.

A useful detail is the distinction between a distribution model, which returns all next-state probabilities, and a sample model, which only draws one plausible next state. A simulator is a sample model; it supports learning and Monte Carlo tree search but not exact expectation sums.

Model-free methods still depend on the transition function, only implicitly. A Q-learning update uses one observed next state as a sample of the expectation, so the environment itself performs the weighting. This is why model-free agents need many more interactions: each sample carries noisy information about the underlying probabilities.

The structure of the transition function also affects difficulty. Sparse transitions, where each action reaches only a few successor states, keep planning cheap, while dense or highly random dynamics increase variance in value estimates and slow learning for every algorithm family.

Known, learned and ignored transition models

Algorithms differ sharply in how they treat the transition function, and this choice shapes their sample efficiency and their vulnerability to errors. The comparison below summarizes the main families.

ApproachUse of the transition functionRepresentative methods
Planning with a known modelGiven exactly by the designerValue iteration, policy iteration
Model-based learningEstimated from experience, then usedDyna architecture, world models
Model-free learningNever represented explicitlyQ-learning, SARSA, policy gradient
Search with a simulatorQueried as a sample modelMonte Carlo tree search
How algorithm families use the transition function

Learned transition models range from count-based tables in small problems to deep networks that predict future latent states. The central risk is model bias: when the learned dynamics are wrong, a planner can exploit those errors and find policies that look excellent in the model but fail in the real environment.

Common mistakes when specifying transition dynamics

Errors in the transition function propagate into every value estimate and policy, so they deserve the same scrutiny as the reward function. The table below lists frequent problems.

MistakeSymptomRemedy
Probabilities not summing to oneValues diverge or shrink oddlyNormalize each row
Missing hidden variablesMarkov assumption violatedEnrich the state or use a POMDP
Overconfident learned modelPolicy exploits model errorsUse ensembles or short rollouts
Simulator ignores noiseSim-to-real performance gapRandomize dynamics during training
Typical transition modeling errors

Another subtle issue is terminal states: an episode end must be modeled as an absorbing state with zero future reward, otherwise value estimates silently include returns that can never be collected.

In everyday language

A transition function is the rulebook for what happens next. You are in some situation. You make a choice. The rulebook says where you might end up and how likely each outcome is.

Think of walking on ice. You try to step forward. Most of the time you move forward, but sometimes you slip sideways. The transition function writes down those chances. A learning agent uses this knowledge, or learns it from experience, to predict the results of its choices and plan better ones.

Seen in the real world

A warehouse operator trains a reinforcement learning controller to decide when to reorder stock. The state is the current inventory level and pending orders, the action is how many units to order, and the transition function captures random daily demand along with delivery delays of two to four days.

Engineers estimate the transition probabilities from two years of sales records, then run value iteration on the resulting model. When the policy is tested against held-out months, it performs well during normal periods but overorders before holidays, because the fitted transition model treated demand as stationary throughout the year.

Adding the calendar week to the state makes the dynamics properly Markov again. The revised policy reduces stockouts and excess inventory in simulation and in a limited live trial, showing how much policy quality depends on accurate transition dynamics.