The Psychology of Reinforcement
Reinforcement learning is both an engineering method and a theory of how animals learn. The prediction/control split of the algorithms mirrors the psychologist's split between classical and instrumental conditioning.
╌╌╌╌
The algorithms in this course were built to solve an engineering problem: an agent in an unknown environment, maximizing reward. But the ideas were not invented in a vacuum. Trial-and-error learning, prediction of upcoming reward, the notion that surprise drives learning — all of these were studied first by psychologists working with animals, decades before the computational theory existed. The correspondence between the two bodies of work is not an accident of vocabulary. It is close enough that the same equations describe a rat pressing a lever and a value-function update, and close enough that reinforcement learning has fed new models back into experimental psychology.1
This lesson argues that reinforcement learning is a theory of learning in animals, not merely a method that borrows animal-learning words. The argument rests on a single alignment: the two families of algorithms in this book — those for prediction and those for control — correspond to the two kinds of conditioning that animal-learning psychology has studied for over a century.
Prediction and control, classical and instrumental
Every algorithm we have built estimates something or improves something. Prediction algorithms estimate a quantity that depends on how the environment is expected to unfold — a value function, the expected discounted return from a state. Control algorithms find a policy that collects more reward. The two are coupled (policy evaluation is prediction; policy improvement is control), but the split is real, and it lines up with the two experimental paradigms of animal learning.2
In classical conditioning (also called Pavlovian conditioning), a stimulus predicts a biologically significant event, and the animal comes to respond to the predictor. The reinforcing event arrives whether or not the animal does anything; the animal has no control over it. What it learns is a prediction. In instrumental conditioning (also called operant conditioning), the reinforcing event is contingent on what the animal does — the apparatus delivers reward or punishment depending on the animal's behavior. What the animal learns is a policy: which action to take. This is control.
The alignment is a convenient first approximation rather than a clean partition. There is more to classical conditioning than pure prediction — the conditioned response is itself an action, so classical conditioning also involves a kind of control, sometimes called Pavlovian control. And the two paradigms interact in most real experiments. But as a way to connect the computational picture to the animal-learning picture, prediction-to-classical and control-to-instrumental is the right first cut.3
Classical conditioning
Pavlov's dogs are the origin. Studying salivation, Pavlov found that an innate reflex — salivating to food in the mouth — could be triggered by an initially neutral stimulus, the sound of a metronome, after the metronome had repeatedly preceded the food.4 The vocabulary that survives from his work:
- The food is an unconditioned stimulus (US): it triggers a response innately, with no learning.
- Salivation to food is the unconditioned response (UR).
- The metronome, initially neutral, becomes a conditioned stimulus (CS) once it reliably predicts the US.
- Salivation to the metronome alone is the conditioned response (CR).
The US is called a reinforcer because it reinforces the production of a CR to the CS. The CR is anticipatory: in a much-studied preparation, a tone CS predicts a puff of air to a rabbit's eye (the US), and the rabbit learns to close a protective membrane before the puff arrives, timed to peak just when the puff is due. Acting in anticipation of important events, rather than merely reacting to them, is adaptive, which is why this ability is widespread across the animal kingdom.5
Two arrangements of the CS and US in time are standard, and the difference matters for the real-time model below. In delay conditioning the CS stays on until the US begins, overlapping it. In trace conditioning the CS ends before the US begins, leaving a gap — the trace interval — that the animal must bridge with some persisting internal signal.
Four phenomena a model must explain
Decades of experiments established properties that any account of classical conditioning has to reproduce. Four are central.6
Acquisition. Over repeated CS–US pairings the CR appears and strengthens, approaching an asymptote set by the US.
Extinction. Present the CS repeatedly without the US and the CR weakens and disappears. Prediction without confirmation decays.
Blocking. This one is the pivotal test. First condition the animal to a tone CS so it predicts the US. Then present a compound CS — tone plus a new light — paired with the same US, over many trials. Finally test the light alone. The animal shows little or no CR to the light: learning about the light has been blocked by the prior learning about the tone.7 Blocking is devastating for the naive theory that conditioning depends only on temporal contiguity — on the CS and US simply co-occurring. The light co-occurs with the US just as reliably as the tone does, yet almost nothing is learned about it. What the animal already predicts, it does not need to learn again.
Higher-order conditioning. A previously conditioned CS can itself act as a US for a new, neutral stimulus. Pavlov conditioned a dog to salivate to a metronome predicting food, then paired a black square with the metronome — never with food. Within a few trials the dog salivated to the black square. The metronome, now a secondary reinforcer, transferred its predictive value to the square. This is second-order conditioning; chains of it are third-order, and so on.8
Blocking is the phenomenon that reshaped the field, because it says plainly that learning is driven by prediction error, not co-occurrence. An animal learns about a stimulus only to the extent that the outcome is surprising — not already predicted by everything else present.
The Rescorla–Wagner model
Rescorla and Wagner built their model mainly to account for blocking. The core idea: an animal learns only when events violate its expectations — only when it is surprised.9
Each component stimulus of a compound CS carries an associative strength , a number for how strongly and reliably that component predicts the US. Consider a compound CS made of components and , with strengths and . What matters on a trial is the aggregate associative strength of everything present, not each component alone. On a trial where the compound is followed by the US, the components update by
with the key assumption that the aggregate strength is the sum, . The symbols:
- is the salience of the CS component (how noticeable it is),
- is a rate parameter tied to the US,
- is the asymptote — the level of associative strength the US can support (Sutton and Barto write here, the magnitude of the reward signal, to avoid confusion with the eligibility-trace ; we keep the classical in this section),
- and the bracket is the prediction error.
The rule is a prediction-error update: each associative strength moves toward a target , by an amount proportional to how far the summed prediction falls short of it. When the aggregate prediction already matches the US, the error is zero and nothing changes. Learning stops when the prediction is right.
A worked acquisition trace
Run numbers through the rule. Take a single CS , so the aggregate strength is just . Fix the product (a salience of , a US rate of ), the asymptote , and start from . The update on every reinforced trial is
Carrying it forward, each trial closes of the remaining gap to :
| trial | before | error | after | |
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 3 | ||||
| 4 | ||||
| 5 | ||||
| 6 |
The strength climbs quickly at first, then slows as the error shrinks, tracing a decaying exponential toward . In closed form the residual gap follows , so — a negatively accelerated acquisition curve, the classic learning-curve shape. Extinction is the mirror image: present with no US, set , and the same rule drives back down by of its remaining height each trial.
How it explains blocking
Blocking falls straight out of the summed-error term. After the tone has been fully conditioned, : the tone alone already predicts the US. Now add the light (initially ) to form the compound. The prediction error on the very first compound trial is
The error is already zero because the tone alone accounts for the US. With no error, , and the light learns nothing, trial after trial. The US is already predicted, so its arrival is no surprise, and surprise is what drives learning. That is blocking, in one line of algebra.
To see the flat line rather than assert it, run phase 2 the same way as the acquisition trace. Pretraining leaves the tone at (its asymptote). Now every compound trial presents and together, so the error uses the sum , and both components share it. With each:
| trial | error | |||||
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | ||||||
| 3 |
The error is pinned at zero from the first compound trial, so on every trial and the light never acquires strength. Contrast this with a control group that sees paired with the US without a pretrained tone: there would run the acquisition trace above, climbing The only difference is the pretrained predictor that zeroes the shared error, which is the summed-error term at work.
From the machine-learning side, the Rescorla–Wagner rule is an error-correction supervised learning rule — essentially the Least-Mean-Square (Widrow–Hoff) rule, a regression algorithm that drives the mean-squared prediction error toward zero.10 Its historical importance was to show that a mechanistic rule, needing no explicit reasoning about which stimulus was added, could account for blocking, when everyone had assumed blocking demanded a cognitive story.
Rescorla–Wagner is the LMS rule, precisely
The animal is doing linear regression: fitting weights so a sum of present cues predicts the US, adjusting those weights by the same error-times-input step a statistician uses. The equivalence to Least-Mean-Square turns the psychology into optimization. Collect the component strengths into a weight vector and describe the compound present on a trial by a binary presence vector , with when component is present. The aggregate prediction is the dot product , exactly the summed associative strength. Define the per-trial squared error against the US level :
Its gradient is , so one step of gradient descent with rate gives
which is the Rescorla–Wagner update, component by component: the factor is why only present components change, and is the shared prediction error. Rescorla and Wagner had, without naming it, written down stochastic gradient descent on squared prediction error — the same rule Widrow and Hoff published for adaptive filters in 1960.11 In this light blocking is a familiar regression fact: the added feature is collinear with a feature already fit to the target, so once explains the US the residual is zero and least-squares assigns the redundant feature zero weight. Overexpectation, below, is the same picture read in the opposite direction.
Overexpectation: a prediction contiguity cannot make
Because the error term sums over everything present, Rescorla–Wagner predicts a phenomenon that a pure co-occurrence account rules out. Train alone to the asymptote, so . Separately train alone to the asymptote, so . Each has been paired with exactly the same US and neither is over-predicting anything on its own. Now present the compound , still followed by the same single US. The summed prediction is now , but the US supports only , so the shared error goes negative:
| trial | error | |||||
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | ||||||
| 3 |
Both strengths fall below the asymptote each earned alone, settling toward where the sum matches . The compound over-predicted the US, so the model unlearns some of what each component had — even though each component is still perfectly contiguous with the US. This is overexpectation, and it is a signature of the summed-error rule: contiguity predicts the strengths should hold, the summed error predicts they drop, and the animal drops them.12
Limitations
Rescorla–Wagner is a trial-level model. It treats a whole trial as one event — a set of components present, one prediction error, one update — and says nothing about what happens within a trial or between trials. That is a serious restriction:13
- It cannot represent the timing of stimuli, so it cannot explain why the CR appears before the US, or how the inter-stimulus interval controls the strength of conditioning.
- It has no mechanism for higher-order conditioning — its updates only ever push strengths toward the US level , and a stimulus never present with the US can never gain strength.
- It cannot address trace conditioning, serial compounds, or the shape of the conditioned response over time.
Every one of these gaps is about time within the trial. The fix is to make the model real-time.
The TD model of classical conditioning
The TD model extends Rescorla–Wagner from a trial-level model to a real-time one. Now labels a small time step within or between trials, not a whole trial. A trial becomes a sequence of states, one per time step, and the animal experiences an endless stream of states , each described by a feature vector . With this move the trial-level restrictions dissolve, and the connection to the rest of this course becomes exact.14
Instead of one update per whole trial, the animal now makes a small update at every instant, comparing what it predicts now to what it predicts a moment later. The three equations below write out that comparison — a value estimate, an error, and a memory of what was recently active.
Let the associative-strength vector be . The aggregate associative strength of a state — the US prediction — is the linear function
which is precisely a value estimate with linear function approximation. The learning update is
where the scalar is the TD error
and is a vector of eligibility traces that decays at rate ,
Here is the prediction target (the US magnitude), is a discount factor, and is the eligibility-trace decay. This reproduces the backward view of semi-gradient with linear function approximation, the prediction algorithm from temporal-difference learning and eligibility traces — the only twist being that here is a US intensity rather than a reward signal.15
The single difference between the two models is the error term. Rescorla–Wagner uses the trial-level prediction error . The TD model uses the temporal-difference error , which compares the prediction at one instant with the discounted prediction at the next instant. Set and the TD model collapses back to Rescorla–Wagner. The bootstrapping term is what buys everything the trial-level model lacked.
Because the TD error carries the term , a change in prediction from one instant to the next is treated exactly like the arrival of a US. This is bootstrapping — a guess corrected toward a later guess — and it is what gives the TD model two things Rescorla–Wagner cannot produce:
- Timing. With a fine-grained state representation, the US prediction grows through the interval between CS and US and peaks at the moment the US is due, and the CR can anticipate the US. The inter-stimulus interval now controls learning.
- Higher-order conditioning. A previously conditioned CS raises , so when it is paired with a new neutral stimulus, the temporal difference in prediction is itself non-zero and drives learning about the new stimulus — with no US present at all. Second- and higher-order conditioning is a direct consequence of bootstrapping.
The TD model is not a perfect account of classical conditioning, but it is a normative one: it says what the animal's nervous system is trying to do during conditioning — form accurate long-term predictions, given the limits of how stimuli are represented and how time is handled. That reframing, from immediate to long-term prediction, is the model's central claim.16
How time gets represented: presence, CSC, and microstimuli
The feature vector is where all the timing lives, and the TD model behaves very differently depending on how a stimulus is turned into features over time. Three representations recur in the literature, and they line up along a temporal generalization gradient — how much a feature active at one instant also speaks for nearby instants.17
The presence representation is the coarsest: one feature per CS, equal to for the whole time the CS is on and otherwise. It carries no information about when within the CS you are, so it forces complete generalization across all times the CS is present. It is not a plausible brain code, yet it is enough to produce most of the timing phenomena below.
The complete serial compound (CSC) is the finest: the onset of a CS starts a
sequence of short, precisely-timed internal signals, one distinct feature per
(CS, elapsed-time) pair — a tapped delay line,
as if the nervous system ran a
clock. Nearby time points share no features, so there is no generalization
between them; the model can learn a separate prediction for each moment. It is
also unrealistic as a brain code (Ludvig and colleagues call it a useful fiction
), but it isolates the model's behavior from the representation, and it is
the representation used in most TD models of dopamine neurons.
The microstimulus (MS) representation sits in the middle. A CS onset launches a cascade of internal features that are extended and overlapping: as time elapses, later microstimuli grow wider in time and reach a lower peak. Overlap means partial generalization between nearby times — coarser than the CSC clock, finer than the single presence feature — and its smeared, decaying shape is closer to what a population of neurons might actually produce.18
Why the CR anticipates the US
With the CSC representation the model learns a US prediction that is not flat across the interval but rising. Discounting is the reason: the value at each state is the discounted prediction of the value one step later, so at asymptote the prediction at time before the US is roughly times the US level, where is the number of steps still to go. That grows toward the US level as the US approaches and peaks exactly at US time. The presence representation, lacking any within-CS timing, gives a near-flat prediction; MS gives a smoothed version of the CSC ramp.
The rising prediction explains a fact the trial-level model cannot touch: the rabbit's protective membrane closes before the air puff, timed to peak when the puff is due. Closing too early wastes vision, closing too late gives no protection, so a CR locked to US time is the adaptive one, and the ramp-and-peak prediction is what supports it.19
ISI tuning and temporal primacy over blocking
Two further predictions of the real-time model have no trial-level analogue. The first is ISI dependence. Conditioning strength depends on the inter-stimulus interval — the gap between CS onset and US onset — in a characteristic inverted-U: it is negligible at a zero or negative ISI (US at or before CS onset), rises to a maximum at some positive ISI, then falls off as the interval grows too long to bridge. The TD model reproduces this shape, with the peak and width set by its discounting and trace parameters.20
The second is sharper, because the model made it before anyone had looked. In ordinary blocking the added CS is simultaneous with the pretrained one. But if the added CS is moved earlier, so its onset precedes the pretrained CS, the TD model predicts that blocking reverses: the earlier stimulus is no longer blocked, and as training continues it gains strength while the later, pretrained stimulus loses it. The reason is bootstrapping. Updates push each state's prediction toward the prediction of the state that follows, so an earlier predictor takes precedence over a later one — temporal primacy overriding blocking. Sutton and Barto reported this prediction in 1981; Kehoe, Schreurs, and Graham confirmed it in 1987 in the rabbit nictitating-membrane preparation, noting that non-TD models struggle with the data.21
From prediction to control
We have followed the prediction half of the correspondence to its end: classical conditioning is prediction, the Rescorla–Wagner rule is a trial-level prediction error, and its real-time TD extension gives the prediction algorithm of this course, with timing, higher-order conditioning, and temporal primacy falling out of bootstrapping. What remains is the other half — control. Instrumental conditioning is the animal learning what to do, not just what to expect, and it maps onto the control side of the theory: the Law of Effect is trial-and-error control, and the habitual/goal-directed distinction is the model-free/model-based split.
This continues in The Psychology of Reinforcement: Instrumental Control.
Footnotes
- Sutton & Barto, Reinforcement Learning, Ch. 14 — Psychology: the correspondences between reinforcement learning and animal learning are striking because they connect ideas arising from different objectives, and psychology's influence on reinforcement learning is real though the two fields' terminologies do not always coincide. ↩
- Sutton & Barto, §14.1 — Prediction and Control: their algorithms fall into prediction and control, which correspond respectively to classical (Pavlovian) and instrumental (operant) conditioning; prediction algorithms are policy-evaluation algorithms that estimate how features of the environment will unfold. ↩
- Sutton & Barto, §14.1 — Prediction and Control: aligning the classical/instrumental distinction with prediction/control is a convenient first approximation; classical conditioning also involves action (
Pavlovian control
), and the two paradigms interact in most experiments. ↩ - Sutton & Barto, §14.2 — Classical Conditioning: Pavlov found an innate salivary reflex could be triggered by an initially neutral stimulus (a metronome) after repeated pairing with food; a neutral stimulus becomes a CS as the animal learns it predicts the US. ↩
- Sutton & Barto, §14.2 — Classical Conditioning: the CR is anticipatory, e.g. a rabbit learns to close its nictitating membrane before an air puff, timed to peak when the puff is due; acting in anticipation of important events is beneficial and widespread across the animal kingdom. ↩
- Sutton & Barto, §14.2.1 — Blocking and Higher-order Conditioning: beyond the anticipatory nature of CRs, blocking and higher-order conditioning are two widely-studied properties that figure prominently in classical-conditioning models. ↩
- Sutton & Barto, §14.2.1 — Blocking: an animal fails to learn a CR to a stimulus presented in compound with a previously-conditioned stimulus; e.g. a light added to a pretrained tone produces few or no CRs when tested alone, challenging the idea that conditioning depends on temporal contiguity. ↩
- Sutton & Barto, §14.2.1 — Higher-order Conditioning: a previously-conditioned CS acts as a US for a new neutral stimulus (Pavlov's black square paired with a food-predicting metronome), producing second-order conditioning and, in principle, higher orders. ↩
- Sutton & Barto, §14.2.2 — The Rescorla–Wagner Model: the model was created mainly to account for blocking; its core idea is that an animal learns only when events violate its expectations, i.e. only when surprised, with the aggregate associative strength of the whole compound (not each component alone) determining the update. ↩
- Sutton & Barto, §14.2.2 — The Rescorla–Wagner Model: from the machine-learning perspective the rule is an error-correction supervised learning rule, essentially the Least-Mean-Square (Widrow–Hoff, 1960) rule that minimizes mean-squared error. ↩
- Widrow & Hoff (1960), Adaptive switching circuits, IRE WESCON Convention Record — the Least-Mean-Square (LMS) rule adjusts weights by , stochastic gradient descent on squared error. Rescorla–Wagner is the same rule with the presence vector as input and the US level as target; the differences noted by Sutton & Barto (§14.2.2) are only that LMS typically uses real-valued inputs and a separate learning rate. Blocking is then the standard fact that a feature collinear with one already fit to the target receives zero weight. ↩
- Sutton & Barto, §14.2.2 — The Rescorla–Wagner Model: because the error uses the aggregate strength of all components present, training two CSs separately to and then presenting them in compound produces a summed prediction above , a negative error, and a decrease in both strengths (
overexpectation
). This follows from the summed-error term and is not predicted by contiguity-only accounts. ↩ - Sutton & Barto, §14.2.2–14.2.3: the Rescorla–Wagner model is a trial-level model that deals with how associative strengths change from trial to trial without considering within-trial or between-trial timing, and it includes no mechanism for higher-order conditioning; the TD model extends it to address these. ↩
- Sutton & Barto, §14.2.3 — The TD Model: the TD model is a real-time model where labels time steps within or between trials; a trial is a sequence of states each represented by a feature vector, and the aggregate associative strength is a value estimate corresponding to the US prediction. ↩
- Sutton & Barto, §14.2.3 — The TD Model: the update with TD error and eligibility trace is equivalent to the backward view of semi-gradient TD() with linear function approximation, except need not be a reward signal; with it reduces to Rescorla–Wagner. ↩
- Sutton & Barto, §14.2.4 / §14.3 preamble: the TD model is a normative account suggesting the nervous system is trying to form accurate long-term predictions; the temporal-difference term has the same status as the US, which is why bootstrapping yields second- and higher-order conditioning. ↩
- Sutton & Barto, §14.2.4 — TD Model Simulations, and Ludvig, Sutton & Kehoe (2012), Learning & Behavior 40,
Evaluating the TD model of classical conditioning
: the presence, complete serial compound (CSC), and microstimulus (MS) representations lie along a temporal generalization gradient — full generalization for presence, none for the CSC tapped-delay-line, intermediate for MS — and the degree of temporal generalization sets the granularity of the learned US prediction. ↩ - Sutton & Barto, §14.2.4, following Ludvig, Sutton & Kehoe (2008/2012): microstimuli are internal signals launched by CS (and US) onset that grow wider and lower over time and overlap, giving partial temporal generalization; they are more realistic than presence or CSC as hypotheses about neural stimulus representations and let the TD model connect to a broader range of conditioning phenomena. ↩
- Sutton & Barto, §14.2.4 — TD Model Simulations: with a fine-grained representation the learned US prediction rises across the CS–US interval and peaks at US time; in the rabbit nictitating-membrane preparation the anticipatory closure grows over the interval and reaches maximal closure at the expected US time, since covering the eye too early impairs vision and too late gives no protection. ↩
- Sutton & Barto, §14.2.4 — TD Model Simulations: conditioning strength typically depends on the inter-stimulus interval (CS-onset to US-onset) as an inverted-U — negligible at zero or negative ISI, maximal at a positive ISI, declining at longer intervals; the TD model reproduces this dependence, with the peak and width set by its discounting and eligibility-trace parameters. ↩
- Sutton & Barto, §14.2.4, Fig. 14.2 (Temporal primacy overriding blocking): the TD model predicts that if the added CS begins before the pretrained CS, blocking is reversed — the earlier CS gains strength and the later pretrained CS loses it — because bootstrapping shifts each state's prediction toward that of later states. Predicted by Sutton & Barto (1981) and confirmed in the rabbit nictitating-membrane preparation by Kehoe, Schreurs & Graham (1987), who noted non-TD models have difficulty with the result. ↩
╌╌ END ╌╌