Concepts / On-Policy Temporal-Difference Control

On-Policy Temporal-Difference Control

The stated convergence guarantee requires two conditions: every state-action pair must be visited an infinite number of times, and the policy must approach the greedy policy in the limit.

  • Programming

The Convergence Question

Sarsa is an on-policy temporal-difference control method, but temporal-difference control alone does not guarantee convergence. The important question is how the policy is connected to Q, the action-value function. As Q changes, the policy may change too, so convergence depends on both continued exploration and the policy's behavior in the limit.

Key point

The stated convergence guarantee requires two conditions: every state-action pair must be visited an infinite number of times, and the policy must approach the greedy policy in the limit.

Early learningExploration is neededState-action visitsEvery pair infinitely oftenLimit behaviorPolicy approaches greedyConvergence guaranteeProbability 1 under bothconditionsQ-valuesContinue to changerequiressupports learningpolicy responds to Qwith infinite visitation
What changes over time in exploration, the policy, and Q-values, and how do the required conditions lead Sarsa toward convergence?

How Q Shapes the Policy

A policy can depend on Q because Q influences which action is treated as preferable. When Q changes, the policy may change as well. This dependence matters because Sarsa's convergence discussion is not about an unrelated, fixed policy; it is about a policy whose behavior is connected to the action-value estimates being learned.

Q-valuesCurrent action-valueestimatesPolicyAction preference from QAction selectionGreedy or randomUpdated Q-valuesQ changes after learninginfluences preferencesets selection behaviorcontributes to learningchanges future policy
How does the current Q-table determine the policy's action probabilities, and how does the resulting action choice feed back into later learning?
Worked example

Two Policy Dependencies

Suppose an agent's Q-values change while it is learning. What should you expect if the policy depends on Q?

  1. 1
    Start with current estimates

    The current Q-values influence which action the policy treats as preferable.

  2. 2
    Change Q

    Learning changes the action-value estimates. Because the policy depends on Q, its action preferences may change too.

  3. 3
    Continue learning

    The agent must still visit every state-action pair an infinite number of times while the policy moves toward greedy behavior.

Result

The policy's dependence on Q is central to the convergence discussion: Q influences the policy, and changes in the policy affect how the agent behaves while learning.

Balancing Exploration and Preference

Definition

An ε-greedy policy chooses the greedy action with probability 1 − ε and a random action with probability ε. The value of ε controls the balance between following the action currently favored by Q and allowing random action selection.

Current stateQ determines preferenceGreedy actionProbability 1 − εRandom actionProbability εfollow preferenceexplore
At a state, how are the probabilities divided between choosing the action favored by Q and choosing randomly?
In the real world

Consider a state where Q currently makes one action the greedy action. Under an ε-greedy policy, the agent usually follows that preference through the 1 − ε portion of the choice, while the ε portion preserves random action selection. The policy therefore uses Q to prefer an action without eliminating random selection entirely.

Shrinking Epsilon Over Time

An ε-greedy policy can move toward greedy behavior by setting ε = 1/t, where t denotes the time step. As t increases, 1/t becomes smaller. Consequently, the probability assigned to random action selection decreases, while the probability assigned to the greedy action, 1 − ε, moves toward 1.

t = 1ε = 1Greedy policyPolicy approaches greedybehaviort = 2ε = 1/2t = 10ε = 1/10Large tε approaches 0t increasest increasest increasesε decreases
How does the exploration probability change across successive time steps, and how does the policy gradually become more greedy?
Worked example

Reading the Schedule

What happens to the random-action probability as t increases under ε = 1/t?

  1. 1
    At t = 1

    The exploration probability is 1/1, or 1.

  2. 2
    At t = 2

    The exploration probability is 1/2, which is smaller than at t = 1.

  3. 3
    As t continues to grow

    The value 1/t becomes smaller, so the probability of random action selection decreases.

Result

The ε-greedy policy approaches greedy behavior because ε moves toward zero and 1 − ε moves toward one.

Checking the Guarantee

The phrase probability 1 describes the strength of the convergence result. It does not mean that every arbitrary policy produces convergence. The visitation condition and the limiting behavior of the policy are essential parts of the claim.

  • Common mistake

    Assuming that temporal-difference control alone guarantees convergence.

    What it looks like

    Sarsa is used, so convergence is treated as automatic.

    Why it fails

    The convergence result depends on how the policy is connected to Q, not merely on the use of temporal-difference control.

    Do this instead

    Check both required conditions: infinite visits to every state-action pair and a policy that approaches the greedy policy.

  • Common mistake

    Treating probability 1 as a guarantee for every policy.

    What it looks like

    Any fixed policy is assumed to receive the same convergence guarantee.

    Why it fails

    The stated result is conditional. It does not apply when the required visitation or limiting-policy condition is missing.

    Do this instead

    Read probability 1 together with the assumptions that precede it.

  • Common mistake

    Checking only whether the policy eventually becomes greedy.

    What it looks like

    A policy becomes greedy, but some state-action pairs stop being visited infinitely often.

    Why it fails

    The policy condition is satisfied, but the infinite-visitation condition is not.

    Do this instead

    Both conditions must hold; satisfying only one is insufficient.

  • Common mistake

    Checking only whether every state-action pair is visited infinitely often.

    What it looks like

    All pairs continue to be visited, but the policy does not converge toward the greedy policy.

    Why it fails

    The visitation condition is satisfied, but the limiting-policy condition is not.

    Do this instead

    Verify both continued visitation and convergence toward greedy behavior.

  • Common mistake

    Treating Q and the policy as unrelated.

    What it looks like

    Changes in Q are assumed to have no effect on action preference.

    Why it fails

    The source identifies the policy's dependence on Q as central to the convergence discussion.

    Do this instead

    Track how Q influences which action is treated as preferable and how policy behavior changes as Q changes.

SetupCondition about visitsCondition about policyMatches the stated guarantee?
Policy becomes greedy, but some pairs are not visited infinitely oftenMissingPresentNo
All pairs are visited infinitely often, but policy does not approach greedy behaviorPresentMissingNo
All pairs are visited infinitely often and policy approaches greedy behaviorPresentPresentYes, under the stated conditions

Sarsa's convergence statement requires both conditions, not just one.

Test Your Understanding

MEDIUM

A proposed Sarsa setup uses an ε-greedy policy with ε = 1/t. Explain why this schedule supports movement toward the greedy policy, then state the additional visitation condition required by the convergence guarantee.

Hints
  • As t increases, what happens to 1/t?
  • What happens to 1 − ε when ε becomes smaller?
  • The convergence claim has two conditions. Name the one concerning state-action pairs.
EASY

Consider two hypothetical cases. Case A reaches greedy behavior but fails to visit some state-action pairs infinitely often. Case B visits every state-action pair infinitely often but does not approach the greedy policy. Which case satisfies the stated convergence guarantee, and why?

Hints
  • List the two required conditions before evaluating the cases.
  • Check each case against both conditions, not just one.

The On-Policy Picture

  1. 1
    Sarsa's convergence depends on the policy's connection to Q, not simply on the fact that Sarsa uses temporal-difference control.
  2. 2
    The stated convergence guarantee requires every state-action pair to be visited an infinite number of times.
  3. 3
    The policy must approach the greedy policy in the limit.
  4. 4
    An ε-greedy policy chooses the greedy action with probability 1 − ε and a random action with probability ε.
  5. 5
    With ε = 1/t, exploration probability decreases as time increases, so the policy moves toward greedy behavior.

Key Takeaways

  • Sarsa's convergence guarantee is conditional rather than automatic.
  • Every state-action pair must be visited an infinite number of times.
  • The policy must approach the greedy policy in the limit.
  • Because the policy depends on Q, changes in Q can change action preferences and policy behavior.
  • An ε-greedy policy with ε = 1/t gradually reduces random action selection and approaches greedy behavior.

Related concepts

More concepts starting with O