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 state | Action | Next state | Probability |
|---|---|---|---|
| Cell (1,1) | Move right | Cell (1,2) | 0.8 |
| Cell (1,1) | Move right | Cell (2,1) | 0.1 |
| Cell (1,1) | Move right | Cell (1,1) | 0.1 |
| Cell (1,2) | Move up | Cell (2,2) | 1.0 |
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.
| Form | Notation | Typical environment |
|---|---|---|
| Deterministic | s′ = f(s, a) | Board games, symbolic puzzles |
| Stochastic, discrete | P(s′ | s, a) as a table | Grid worlds, inventory problems |
| Stochastic, continuous | Density p(s′ | s, a) | Robotics, physical control |
| Joint with reward | p(s′, r | s, a) | General textbook formulation |
| Non-stationary | P changes over time | Markets, opponents that adapt |
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.
| Approach | Use of the transition function | Representative methods |
|---|---|---|
| Planning with a known model | Given exactly by the designer | Value iteration, policy iteration |
| Model-based learning | Estimated from experience, then used | Dyna architecture, world models |
| Model-free learning | Never represented explicitly | Q-learning, SARSA, policy gradient |
| Search with a simulator | Queried as a sample model | Monte Carlo tree search |
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.
| Mistake | Symptom | Remedy |
|---|---|---|
| Probabilities not summing to one | Values diverge or shrink oddly | Normalize each row |
| Missing hidden variables | Markov assumption violated | Enrich the state or use a POMDP |
| Overconfident learned model | Policy exploits model errors | Use ensembles or short rollouts |
| Simulator ignores noise | Sim-to-real performance gap | Randomize dynamics during training |
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.