Starting from ∇θJ(θ)=Eτ[∑t∇θlog⁡πθ(at∣st)∑krk+1], prove that rewards received before time t can be dropped from the factor multiplying ∇θlog⁡πθ(at∣st). What does this give you, and what is a subtle mistake with the discount factor?

Reinforcement learning, Policy gradients
Level L4 Advanced. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can prove the causality argument (an action cannot affect earlier rewards) using the zero-mean property of the score function.

Key idea

For k<t, the reward rk+1 is already fixed by the history before at is chosen, and Eat∼π[∇log⁡π(at∣st)]=0. So E[∇log⁡π(at∣st) rk+1]=0 for k<t, and only the reward-to-go ∑k≥trk+1 remains.

Steps

  1. Expand the sum. ∇J=∑t∑kE[∇log⁡π(at∣st) rk+1]. We show that the terms with k<t are zero.
  2. Fix k<t. Let ht=(s0,a0,r1,…,st) be the history up to the state at time t. The reward rk+1 is a function of ht, because it was received at or before time k+1≤t.
  3. Condition on ht (law of total expectation): E[∇log⁡π(at∣st) rk+1]=E[rk+1  E[∇log⁡π(at∣st)∣ht]].
  4. The inner expectation is ∑aπ(a∣st)∇log⁡π(a∣st)=∑a∇π(a∣st)=∇∑aπ(a∣st)=∇1=0. So the whole term is 0.
  5. Therefore ∇J=E[∑t∇log⁡π(at∣st) Gt] with Gt=∑k≥trk+1. The estimator is still unbiased.
  6. The benefit is lower variance. We removed the terms with zero mean but non-zero variance, and the returns before t only added noise.
  7. Subtle point on discounting. The exact gradient of ∑tγtrt+1 has the factor γt in front of the score at time t. Most implementations drop this factor. The result is then not the true gradient of the discounted objective, because it gives later states more weight than they should have.

Common mistakes

How long your answer should be

A page; 6–8 minutes.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: What is the "deadly triad" in reinforcement learning? How do you show with a two-state example, with V^(s1)=w and V^(s2)=2w, a single weight w, and reward 0 everywhere, that off-policy semi-gradient TD(0) can diverge when only the transition s1→s2 is updated?
Next in Reinforcement learning: TRPO maximises a surrogate improvement subject to a KL bound. Linearise the objective as g⊤Δ and the constraint as 12Δ⊤FΔ≤δ, where g is the policy gradient and F is the Fisher information matrix. Derive the step Δ. For g=(1,1)⊤, F=diag(4,1) and δ=0.02, what is Δ, and how does its improvement g⊤Δ compare with a plain gradient step that uses the same KL?