Evaluation lab · San Francisco · London · Zürich
Reinforced Labs Request a briefing
Glossary

Q-function

Also called: action-value function, Q(s,a), Q-value, Qπ, Q*

The Q-function Q(s,a) gives the expected return from taking action a in state s and then following a policy; acting greedily on Q picks the best action.

The Q-function, or action-value function, is the expected discounted return from taking action in state and following policy afterwards. Where the state-value function scores situations, the Q-function scores choices.

Definition

The first action is fixed; only later actions follow . The two value functions are linked by : the value of a state is the policy-weighted average of its action values. The optimal Q-function satisfies the Bellman optimality equation

Why learn Q rather than V

If you know , the optimal policy is simply . No model of the transitions is needed to make the choice. With only , choosing an action requires looking one step ahead through , which model-free agents do not have. This is why Q-learning and its deep variants learn directly.

Worked example

Take a state where going left earns 1 and ends the episode, and going right earns 0 and leads to a state worth 8, with . Then and . A policy that picks each with probability 0.5 has . The greedy policy picks right, and the advantage of right is : how much better it is than the policy's average behaviour.

In practice

Tabular Q-functions store one number per state-action pair. Deep Q-networks output a vector of Q-values for all discrete actions in one forward pass. For continuous actions, actor-critic methods learn as a critic and train a separate actor to maximise it. Learned Q-values tend to be overestimated, because taking a max over noisy estimates is biased upward; double Q-learning addresses this by using one estimator to choose the action and another to evaluate it.

Why it matters

The Q-function is the bridge between evaluation and control: it tells you not just how well a policy does, but which single change would improve it. That one-step improvement, , is the policy improvement theorem behind policy iteration, and the same quantity, minus a baseline, drives policy gradient updates.

Sources

  1. Richard S. Sutton, Andrew G. Barto. Reinforcement Learning: An Introduction (2nd edition), 2018. incompleteideas.net

Know the number before you ship.

A 45-minute working session with an evaluation engineer. Bring one use case; leave with a threat model, a draft eval plan with sample sizes, and an honest read on where you stand.