State-Value and Action-Value Functions
Once returns are defined, we can ask how good a situation is before the episode is over. In a maze, some positions make high future return more likely even before the agent reaches the goal.
A policy is the agent's decision rule. We write for the probability of taking action in state . A deterministic policy puts all probability on one action. A stochastic policy spreads probability across actions.
The behavior we want to optimize is the policy. The optimal policy is written In words: find the policy that maximizes expected return.
Notation Map
- : the current state at time .
- : the sampled next state produced by the environment.
- : a symbol ranging over possible next states.
- : the action taken in state .
- : a candidate next action.
- : the policy's probability of taking action in state .
A state-value function evaluates being in a state and then following a policy:
Read this as: the value of state under policy is the expected return, assuming the agent starts in state at time and follows afterward. The expectation is necessary because the policy may be stochastic and the environment may be uncertain.
An action-value function evaluates one first action and then following the policy:
Read this as: how good it is to be in state , take action now, and then follow policy afterward. The difference is practical: answers "what if I take this action first?" while answers "how good is this state if I behave according to this policy?"
V versus Q
Two different questions at the same state
At the fork, Q asks about one named first action. V asks about the state under the policy's usual behavior.
Situation
The agent is at one fork in a maze. It can take a shortcut or a safe path.
Q question
What if the first action is shortcut?
Q(s, shortcut) = 2.0
Q question
What if the first action is safe path?
Q(s, safe) = 5.0
Choose the policy pi(a | s)
V question
If the agent follows this policy from the fork, how good is the state on average?
The Q values stay fixed. The V value changes because the policy changes which action is more likely.
The two values are action-specific: shortcut has one value, safe path has another. The value is the average return from the state if the policy chooses actions with its usual probabilities.
That is why is policy-dependent. The action-values can stay fixed while the state-value changes, because a different policy changes how often each action is chosen.
The relationship is This is a weighted average. Each is counted in proportion to how often policy takes action in state .
When Q Is Especially Useful
If the agent must choose an action now, is directly comparable across actions. A state-value summarizes how good the state is under the policy.
Choosing the Highest-Q Action
Because scores a specific action in a specific state, an agent can choose the action with the highest Q-value:
In the maze example, suppose and . A greedy agent chooses the safe path because it has the higher estimated return from the current state.
This rule is called greedy action selection. It is useful when the Q-values are reliable, but early in learning the highest current Q-value may simply reflect a lucky estimate. That is why later sections introduce exploration.
Why can change when the policy changes even if the environment and rewards stay fixed?