How do you derive the REINFORCE policy-gradient estimator, and why does subtracting a baseline not introduce bias?
Reinforcement learning, Policy gradients
Level L3 Intermediate. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can use the log-derivative trick, handle trajectory probabilities, and argue about variance reduction.
Key idea
Let be the policy (the probability of action in state ), a trajectory and the reward-to-go from step . Then . The environment dynamics drop out of , and , so a baseline that depends only on the state is unbiased.
Steps
- Define the expected return , where is the total reward of trajectory .
- Use (the log-derivative trick) to move the gradient inside the expectation. This matters because an expectation can be estimated by sampling.
- Expand , where is the start-state distribution and gives the transition probabilities. Only the policy terms depend on .
- Use causality to replace with the reward-to-go : an action cannot affect rewards that came before it.
- Show that the baseline term vanishes: This works for any , because it can be taken outside the sum over .
- Note that a good baseline, such as the value function , reduces variance. This leads to actor-critic methods and advantage estimates.
Common mistakes
- Trying to differentiate through the environment dynamics.
- Letting the baseline depend on the action, which does introduce bias.
- Confusing the score-function (log-derivative) estimator with the reparameterisation trick.
How long your answer should be
One page; 8–10 minutes.
Last checked on 4 December 2026.
Read this
Previous in Reinforcement learning: For a sampled transition, , , and the next state has online-network values and target-network values . Compute the target used by DQN and by double DQN. Why does the max in DQN cause over-estimation, and how does double DQN reduce it?
Next in Reinforcement learning: Derive the Bellman expectation equation for . How does the Bellman optimality equation for differ, and why can the first be solved as a linear system but not the second?