Papersseum

Learn › Reference

Maths cheat sheet

Every formula in the course on one page. Symbols first, then the formulas, grouped by chapter.

Symbols

SymbolMeaning
ss, s′s'a state, and the next state
aaan action
rr, RRa reward
γ\gammadiscount factor, between 0 and 1
GtG_tthe return from time tt
π(a∣s)\pi(a \mid s)probability the policy picks aa in state ss
V(s)V(s)value of a state
Q(s,a)Q(s, a)value of taking aa in state ss
α\alphastep size (learning rate)
ε\varepsilonexploration probability

Averages and bandits

Expected value of a quantity that takes value xix_i with probability pip_i:

E[X]=∑ipixi.E[X] = \sum_i p_i x_i.

Running average, after a new observation xx (this is the pattern behind nearly every update in the course):

new estimate=old estimate+α (x−old estimate).\text{new estimate} = \text{old estimate} + \alpha\,(x - \text{old estimate}).

Returns and MDPs

Gt=Rt+1+γRt+2+γ2Rt+3+⋯G_t = R_{t+1} + \gamma R_{t+2} + \gamma^2 R_{t+3} + \cdots

Bellman equations

Vπ(s)=∑aπ(a∣s)∑s′P(s′∣s,a) [r+γVπ(s′)]V^\pi(s) = \sum_a \pi(a \mid s) \sum_{s'} P(s' \mid s, a)\,\big[r + \gamma V^\pi(s')\big] V∗(s)=max⁡a∑s′P(s′∣s,a) [r+γV∗(s′)]V^*(s) = \max_a \sum_{s'} P(s' \mid s, a)\,\big[r + \gamma V^*(s')\big]

Learning from experience

Monte Carlo: move the estimate toward the return of the whole episode.

V(s)←V(s)+α (G−V(s))V(s) \leftarrow V(s) + \alpha\,\big(G - V(s)\big)

TD(0): move it toward the reward plus the estimate of the next state.

V(s)←V(s)+α (r+γV(s′)−V(s))V(s) \leftarrow V(s) + \alpha\,\big(r + \gamma V(s') - V(s)\big)

SARSA (on-policy):

Q(s,a)←Q(s,a)+α (r+γQ(s′,a′)−Q(s,a))Q(s,a) \leftarrow Q(s,a) + \alpha\,\big(r + \gamma Q(s',a') - Q(s,a)\big)

Q-learning (off-policy):

Q(s,a)←Q(s,a)+α (r+γmax⁡a′Q(s′,a′)−Q(s,a))Q(s,a) \leftarrow Q(s,a) + \alpha\,\big(r + \gamma \max_{a'} Q(s',a') - Q(s,a)\big)

Gradient descent and networks

Step against the slope of the error EE with respect to a weight ww:

w←w−α dEdw.w \leftarrow w - \alpha \,\frac{dE}{dw}.

A neuron: a weighted sum, then a bend (an activation function such as the ReLU, which is max⁡(0,z)\max(0, z)):

output=f(w1x1+w2x2+⋯+b).\text{output} = f\big(w_1 x_1 + w_2 x_2 + \cdots + b\big).

DQN

Target and loss:

target=r+γmax⁡a′Qtarget net(s′,a′),loss=(Q(s,a)−target)2.\text{target} = r + \gamma \max_{a'} Q_{\text{target net}}(s', a'), \qquad \text{loss} = \big(Q(s,a) - \text{target}\big)^2.

Policy gradients

Softmax:

π(a)=eθa∑jeθj.\pi(a) = \frac{e^{\theta_a}}{\sum_j e^{\theta_j}}.

For a softmax, the slope of ln⁡π(a)\ln \pi(a) with respect to the scores is "one-hot minus probabilities". The update after taking action aa with advantage AA:

θ←θ+α A ∇ln⁡π(a).\theta \leftarrow \theta + \alpha\, A\, \nabla \ln \pi(a).

Elo

EA=11+10(RB−RA)/400,RA←RA+K (SA−EA).E_A = \frac{1}{1 + 10^{(R_B - R_A)/400}}, \qquad R_A \leftarrow R_A + K\,(S_A - E_A).