Temporal difference learning shares many of the benefits of both dynamic programming methods and Monte Carlo methods without many their disadvantages. Like dynamic programming methods, policy evaluation can be updated at each time step but unlike dynamic programming you do not need a model of the environment. Like Monte Carlo methods, you do not need a model of the environemt but unlike Monte Carlo methods you do not need to wait til the end of an episode to make a policy evaluation update. All three of these methods use the same policy iteration strategy which iterates between policy evaluation (different for each method) and policy improvement (in a greedy fashion for each method).

The value-function update formula for temporal difference learning is

where is the observed reward of the next time step and is the estimate of the value of the next time step. Since TD learning uses an existing estimate it is known as a *bootstrapping* method (like DP methods). This TD update algorithm is guaranteed to converge to the value function of a given policy as long as the step size parameter is sufficiently small.

## Sarsa (On-Policy TD Learning)

Recall that for on-policy methods, the value function is learned by following the associated policy (with some exploration strategy like -greedy). Sarsa is concerned with learning an action-value function for a given policy rather than just the value function, however essentially the same update is used.

If you take a close look at the update formula you will see that it involves the current state , the current action , the reward observed from that action , the next state , and the next action . If you combine these symbols together you get which is how you get the name.

## Q-Learning (Off-Policy TD Learning)

Recall the for off-policy methods, the value function for a given policy is learned by following a different policy. The Q-learning update function is

So this update formula will end up estimating no matter what policy is being observed. The only requirement is that the policy being observed updates all state-action pairs.

Thank you for reading.