Skip to content
AI360XpertBeta

Transition Dynamics

Transition dynamics are the environment's physics written as probabilities: for each state and action, they say how likely every possible next state is.

Action Forward from Safe Road branches to three next states with probabilities 0.10, 0.70 and 0.20, and the goal holds 0.57 after two steps
Action Forward from Safe Road branches to three next states with probabilities 0.10, 0.70 and 0.20, and the goal holds 0.57 after two steps

Why Does This Exist?

Real environments ignore your intentions. A robot issues a drive command and hits slippery ice. A delivery drone banks right and meets a gust. A router forwards a packet and a buffer drops it. If your planner assumes each action lands exactly one next state, the first patch of noise shreds the plan.

Transition dynamics are the fix: for every state ss and action aa, they give a probability distribution over next states s′s'. With that distribution you can compute expected returns, hedge against bad outcomes, and plan in uncertain worlds. Without it, the core machinery of Markov decision processes, Bellman equations, and value functions cannot even state what "good" means, because every one of them averages over what happens next.

Think of It Like This

Driving on an icy road

You approach an intersection on a winter highway and turn the wheel 30 degrees right. That command is your action aa; your position and velocity are your state ss.

On dry asphalt the outcome is near certain: you enter the right lane. On ice, traction physics decouples intention from outcome, and one command produces a distribution. Say 70 percent of the time the tires bite and you track into the right lane. 15 percent of the time the wheels lose grip and momentum skids you straight into the intersection. 15 percent of the time slush catches the left tires and pulls you onto the shoulder.

You do not control which outcome occurs on any single attempt. The ice, the rubber, and the laws of friction decide. Your only lever is choosing which gamble to take.

Where the analogy stops: a human driver corrects continuously with live feedback. A discrete-time MDP agent commits to one action ata_t for the whole step, and the transition kernel samples st+1s_{t+1} in one atomic move before the next observation arrives.

How It Actually Works

The kernel: one distribution per state and action

Write P(s′∣s,a)P(s' \mid s, a) for the probability that the environment lands in s′s' at time t+1t+1 given state ss and action aa at time tt:

P(s′∣s,a)≐Pr⁡(St+1=s′∣St=s,At=a)P(s' \mid s, a) \doteq \Pr(S_{t+1} = s' \mid S_t = s, A_t = a)

This rests on the Markov property: the distribution depends only on the current pair (s,a)(s, a), never on the longer history. That is what makes the object small enough to work with.

The textbook joint form p(s′,r∣s,a)p(s', r \mid s, a) adds the reward rr into the same distribution: the probability of landing in s′s' collecting rr. You recover the transition kernel by summing the reward away, P(s′∣s,a)=∑rp(s′,r∣s,a)P(s' \mid s, a) = \sum_r p(s', r \mid s, a), and the expected immediate reward by weighting rewards the same way, R(s,a)=∑rr∑s′p(s′,r∣s,a)R(s, a) = \sum_r r \sum_{s'} p(s', r \mid s, a). One object feeds both planning and evaluation.

Rows must sum to one

Because P(⋅∣s,a)P(\cdot \mid s, a) is a probability distribution, every row sums to exactly 1 and no entry goes negative:

∑s′P(s′∣s,a)=1for every s,a\sum_{s'} P(s' \mid s, a) = 1 \quad \text{for every } s, a

For a finite state space with nn states, each action aa owns an n×nn \times n transition matrix Pa\mathbf{P}^a whose entry (i,j)(i, j) is P(sj∣si,a)P(s_j \mid s_i, a). Every row sums to 1, which makes it a right-stochastic matrix. Follow a fixed policy π\pi and the whole system collapses to one matrix, [Pπ]i,j=∑aπ(a∣si)P(sj∣si,a)[\mathbf{P}^\pi]_{i,j} = \sum_a \pi(a \mid s_i) P(s_j \mid s_i, a), so a state distribution μt\boldsymbol{\mu}_t evolves by plain multiplication, μt+1=μtPπ\boldsymbol{\mu}_{t+1} = \boldsymbol{\mu}_t \mathbf{P}^\pi. Probability mass is never created or destroyed, only moved.

Worked example: two steps down an icy corridor

Three states: s1s_1 Safe Road, s2s_2 Icy Patch, s3s_3 Goal (absorbing, so it keeps itself with probability 1). One action, Forward, with matrix:

PForward=[0.100.700.200.200.300.500.000.001.00]\mathbf{P}^{\text{Forward}} = \begin{bmatrix} 0.10 & 0.70 & 0.20 \\ 0.20 & 0.30 & 0.50 \\ 0.00 & 0.00 & 1.00 \end{bmatrix}

Row check: 0.10+0.70+0.20=1.000.10 + 0.70 + 0.20 = 1.00, 0.20+0.30+0.50=1.000.20 + 0.30 + 0.50 = 1.00, 0+0+1=1.000 + 0 + 1 = 1.00. Start certain in s1s_1, so μ0=[1.00,0.00,0.00]\boldsymbol{\mu}_0 = [1.00, 0.00, 0.00].

After one step, μ1=μ0P=[0.10,0.70,0.20]\boldsymbol{\mu}_1 = \boldsymbol{\mu}_0 \mathbf{P} = [0.10, 0.70, 0.20], just the first row. After two steps, multiply again:

μ2,1=0.10(0.10)+0.70(0.20)+0.20(0.00)=0.01+0.14=0.15\mu_{2,1} = 0.10(0.10) + 0.70(0.20) + 0.20(0.00) = 0.01 + 0.14 = 0.15 μ2,2=0.10(0.70)+0.70(0.30)+0.20(0.00)=0.07+0.21=0.28\mu_{2,2} = 0.10(0.70) + 0.70(0.30) + 0.20(0.00) = 0.07 + 0.21 = 0.28 μ2,3=0.10(0.20)+0.70(0.50)+0.20(1.00)=0.02+0.35+0.20=0.57\mu_{2,3} = 0.10(0.20) + 0.70(0.50) + 0.20(1.00) = 0.02 + 0.35 + 0.20 = 0.57

So μ2=[0.15,0.28,0.57]\boldsymbol{\mu}_2 = [0.15, 0.28, 0.57], summing to 1.00, with a 57 percent chance of already holding the goal. These are the numbers in the diagram above.

Now use the same row to price an action. With values V=[2.00,5.00,10.00]V = [2.00, 5.00, 10.00], step reward −1.00-1.00, and discount γ=0.90\gamma = 0.90:

E[V(s′)]=0.10(2.00)+0.70(5.00)+0.20(10.00)=0.20+3.50+2.00=5.70\mathbb{E}[V(s')] = 0.10(2.00) + 0.70(5.00) + 0.20(10.00) = 0.20 + 3.50 + 2.00 = 5.70 Q(s1,Forward)=−1.00+0.90×5.70=−1.00+5.13=4.13Q(s_1, \text{Forward}) = -1.00 + 0.90 \times 5.70 = -1.00 + 5.13 = 4.13

That weighting, probabilities times future values, is exactly what a Bellman update does. Without the dynamics row, the expectation cannot be written down.

Code

The snippet propagates the distribution two steps and prices the action, printing the same numbers the worked example derived.

from typing import List

def step_distribution(mu: List[float], row_of: List[List[float]]) -> List[float]:    """One distribution step: mu_{t+1}[j] = sum_i mu_t[i] * P[i][j]."""    n = len(row_of)    return [sum(mu[i] * row_of[i][j] for i in range(n)) for j in range(n)]

if __name__ == "__main__":    P = [[0.10, 0.70, 0.20], [0.20, 0.30, 0.50], [0.00, 0.00, 1.00]]    mu0 = [1.0, 0.0, 0.0]    mu1 = step_distribution(mu0, P)    mu2 = step_distribution(mu1, P)    print([round(p, 2) for p in mu1])  # -> [0.1, 0.7, 0.2]    print([round(p, 2) for p in mu2])  # -> [0.15, 0.28, 0.57]    values = [2.0, 5.0, 10.0]    expected_next = sum(p * v for p, v in zip(P[0], values))    q = -1.0 + 0.9 * expected_next    print(round(expected_next, 2))  # -> 5.7    print(round(q, 2))  # -> 4.13

Watch Out For

Planning on deterministic physics, deploying on noise

The symptom: a planner finds a brilliant trajectory that threads hazards with zero margin (driving along the cliff edge because the planned path technically never touches it), then the hardware version falls apart on the first gust, friction patch, or control delay.

The cause is a simulator or model that treats physics as deterministic, P(s′∣s,a)=1P(s' \mid s, a) = 1 for one successor. The fix: put the noise in before planning, not after. Randomize friction, mass, and latency across rollouts, or plan against the stochastic kernel directly so the optimizer pays for risk. If your sim-to-real gap appears exactly where margins were thinnest, this was it.

Rows that do not sum to one

The symptom: value estimates drift to infinity or decay toward zero for no visible reason. The cause is a dynamics table or learned model whose rows sum to 1.05 (inventing probability mass every Bellman backup) or 0.95 (leaking it).

The fix: assert the invariant where the dynamics are built. Every row must sum to 1.01.0 within tolerance and hold no negatives. For a learned model, project successor logits through a softmax so normalization holds by construction.

The Quick Version

  • Transition dynamics P(s′∣s,a)P(s' \mid s, a) assign every state-action pair a probability distribution over next states, which is the environment's physics in equation form.
  • The Markov property keeps the object small: the next distribution depends only on the current state and action, not the history.
  • Every row of every transition matrix sums to exactly 1, so state distributions evolve by multiplication with no mass created or lost.
  • Bellman updates weight future values by these probabilities (here 0.10,0.70,0.200.10, 0.70, 0.20 giving Q=4.13Q = 4.13); model-based RL plans with the matrix while model-free methods sample from it.
  • Deterministic planning on stochastic hardware fails at the thinnest margin, and rows that do not sum to one corrupt every value built on them.