Equations · Bellman, “Dynamic Programming” (1957); this expectation form for a fixed policy is the standard one in reinforcement learning
The Bellman equation, explained term by term
The value of a state equals the expected immediate reward plus the discounted value of wherever you land next. It turns a sum over an entire future into a one-step relation between neighbouring states, which is what most RL algorithms solve or approximate.
Term by term
The value of state under policy : the expected return when starting in and following . Many papers write .
Value function V · Subscript (index or label) · State s and action a
Average over the actions the policy might take in , weighted by their probabilities. is the policy, not 3.14.
Average over what the environment does next: the probability of landing in state with reward after taking in . The prime marks "the next state".
A small worked example
In state the policy picks each of two actions with probability , and . Action 1 gives reward 1 and leads to a state with value 10; action 2 gives 0 and leads to a state with value 4. Then . The optimal version replaces the average over actions with a max: .
In code
import numpy as np
def evaluate_policy(P, R, pi, gamma=0.9, iters=500):
# P[s, a, s2]: transition probs; R[s, a]: expected reward; pi[s, a]: policy
v = np.zeros(P.shape[0])
for _ in range(iters): # apply the Bellman equation until it settles
q = R + gamma * P @ v # (S, A)
v = (pi * q).sum(axis=1)
return vEvery symbol in it
Other equations
- Scaled dot-product attention
- Softmax
- Cross-entropy loss
- Adam update
- Layer normalization
- RMSNorm
- The ELBO
- KL divergence
- Backpropagation through one layer
- LoRA
- GELU
- Dropout
- Batch normalization
- Rotary position embedding (RoPE)
- Multi-head attention
- PPO clipped objective
- DPO loss
- Policy gradient (REINFORCE)
- Q-learning update
- InfoNCE contrastive loss
- Diffusion forward process
- DDPM simplified loss
- VAE reparameterization trick
- GAN minimax objective
- AdamW
- Cosine learning-rate schedule
- Perplexity
- Logistic regression
- Normal equation (linear regression)
- Singular value decomposition (SVD)
- Principal component analysis (PCA)