Baselines & Variance Reduction
The Variance Problem
Section titled “The Variance Problem”REINFORCE’s gradient estimate has high variance because the return can vary wildly between episodes. This means we need many samples for a reliable gradient, making training slow.
Adding a Baseline
Section titled “Adding a Baseline”We can subtract a baseline from the return without introducing bias:
Why is this still unbiased? Because:
The baseline doesn’t change the expected gradient — it only reduces variance.
The Value Function Baseline
Section titled “The Value Function Baseline”The best common choice for the baseline is the state-value function :
This turns the weight from into the advantage:
The advantage is positive when the action was better than average, and negative when it was worse. This is much more informative than the raw return.
Interactive: Watch the Variance Shrink
Section titled “Interactive: Watch the Variance Shrink”A 2-action bandit with Gaussian rewards. We draw N samples and form the REINFORCE single-sample gradient estimate with and without the value-function baseline. Both have the same mean (the proof above) but visibly different spread.
Worked Example
Section titled “Worked Example”With , policy :
A single sample where action is taken and reward is observed:
| Quantity | No baseline | With baseline |
|---|---|---|
| advantage | ||
| score | ||
| gradient |
If action is taken with :
| Quantity | No baseline | With baseline |
|---|---|---|
| advantage | ||
| score | ||
| gradient |
The baselined gradients are both small and same-signed (positive — both actions look slightly above average given the noisy draw); the unbaselined ones are huge and opposite-signed, even though the average return doesn’t actually distinguish the actions much.
Interactive: The Baseline Race
Section titled “Interactive: The Baseline Race”The sampler above shows the spread of a single gradient estimate. Here is what that spread costs over a whole training run: two REINFORCE learners racing live on the same bandit, identical in every way except the baseline.
What it models. Two identical REINFORCE learners on the same 5-armed bandit (true mean rewards 3.2–3.8, best arm marked ▲); the only difference is that B subtracts a running-average-reward baseline before each update. Every reward is positive, so the plain learner A pushes up whichever arm it happens to sample — its updates are dominated by the constant +3 reward floor rather than by which arm is actually better, and it sometimes locks onto the wrong arm for good.
Knobs. The learning rate α is shared by both learners; σ is the reward noise around each arm’s mean.
Try this. Crank σ to 1.2 and watch the race gap widen — A whipsaws across the π = 0.8 line and takes roughly 3× longer to stay there, while B still climbs cleanly every run. Then drop σ to 0: A’s red gradient trace barely falls, because its variance never came from reward noise — it is the baseline-removable offset term, the same one that blows up the no-baseline gradients in the worked example above.
Actor-Critic
Section titled “Actor-Critic”When we learn both:
- A policy (the actor)
- A value function (the critic)
we get an actor-critic method. The critic provides the baseline, and the actor updates using the advantage:
This is the foundation for PPO, which we’ll cover next.
Summary
Section titled “Summary”| Method | Weight | Bias | Variance |
|---|---|---|---|
| REINFORCE | None | High | |
| With baseline | None | Lower | |
| Actor-Critic | Some (bootstrapping) | Lowest |
The bias-variance tradeoff is a recurring theme — we’ll see it again with GAE in the PPO section.
References
Section titled “References”- Williams. Simple Statistical Gradient-Following Algorithms for Connectionist Reinforcement Learning. Machine Learning 8, 1992 — already includes the baseline. Springer
- Greensmith, Bartlett, Baxter. Variance Reduction Techniques for Gradient Estimates in Reinforcement Learning. JMLR 5, 2004 — the formal analysis of which baselines minimize variance. JMLR