> For the complete documentation index, see [llms.txt](https://slm-lab.gitbook.io/foundations-of-deep-rl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://slm-lab.gitbook.io/foundations-of-deep-rl/book-errata/chapter-2-reinforce.md).

# Chapter 2 REINFORCE

### Page 26, Section 2.2 The Objective Function, Equation 2.1

Equation 2.1 misplaces the prime symbol due to a Latex formatting error. It was

$$
R\_t(\tau) = \sum\_{t'=t}^T \gamma^{t'-t} r\_t' \ \ \ \ \ \  (\text{misplaced prime on } r')
$$

Instead it should have been

$$
R\_t(\tau) = \sum\_{t'=t}^T \gamma^{t'-t} r\_{t'}
$$

### Page 27, Section 2.3 The Policy Gradient, Equation 2.3

Equation 2.3 contains a typo. Following from equation 2.2, the max argument should be applied on both side of the equation. It was,

$$
\max\limits\_\theta \textit{J}(\pi\_\theta) =
\mathbb{E}*{\tau\thicksim\pi*\theta} \[\textit{R}(\tau)] \ \ \ \ \ \  (\text{missing max on the right})
$$

Instead it should have been

$$
\max\limits\_\theta \textit{J}(\pi\_\theta) = \max\limits\_\theta
\mathbb{E}*{\tau\thicksim\pi*\theta} \[\textit{R}(\tau)]
$$

### Page 28, Section 2.3.1 Policy Gradient Derivation, Equation 2.9

In the chain of derivation, equation (2.9) states that the step used is *(chain-rule)*, but in fact it is *(product-rule)*.

### Page 30, Section 2.3.1 Policy Gradient Derivation, Equation 2.21

Equation 2.21 misses a step in derivation:

> By substituting Equation 2.20 into 2.15 and bringing in the multiplier R(τ), we obtain

$$
\nabla\_\theta J(\pi\_\theta) = E\_{\tau \sim \pi\_\theta} \big\[\sum\_{t=0}^T R\_t(\tau) \nabla\_\theta \log \pi\_\theta(a\_t|s\_t) \big] \ \ \ \ \ \  (2.21)
$$

Actually, the substitution yields:

$$
\nabla\_\theta J(\pi\_\theta) = E\_{\tau \sim \pi\_\theta} \big\[\sum\_{t=0}^T R(\tau) \nabla\_\theta \log \pi\_\theta(a\_t|s\_t) \big] \ \ \ \ \ \  (\text{missing step 1})
$$

There is an additional step which modifies R(τ) to give us equation 2.21. The form above has a high variance due to the many possible actions over a trajectory. One way to reduce the variance is to account for causality by only considering the future rewards for any given time step t. This makes sense since event occurring at time step t can only affect the future but not the past. To do so, we modify R(τ) as follows:

$$
R(\tau) = R\_0(\tau) = \sum\_{t'=0}^T \gamma^{t'} r\_{t'} \rightarrow \sum\_{t'=t}^T \gamma^{t'-t} r\_{t'} = R\_t(\tau) \ \ \ \ \ \  (\text{missing step 2})
$$

With this, we obtain equation 2.21.
