How dopamine builds habits: the reward prediction error

Dopamine is not a pleasure chemical. It is a teaching signal that fires when life beats your forecast, and that one fact explains why cues, not rewards, end up running your habits.

Adult male rhesus macaque sitting in a forest in Nepal
Photo: Charles J. Sharp, CC BY-SA 4.0, via Wikimedia Commons

Dopamine builds habits by signalling a reward prediction error: the gap between the reward you expected and the reward you got. Midbrain dopamine neurons fire a burst when an outcome is better than forecast, stay flat when it is exactly as forecast, and dip below baseline when it is worse. With repetition the burst moves from the reward to the earliest cue that predicts it, so the cue, not the reward, starts driving the behaviour.

Key takeaways
  • Prediction error: dopamine neurons report "better or worse than expected", not pleasure.
  • 55–80% of midbrain dopamine neurons share the same phasic reward response.
  • The burst moves to the cue: after learning, the light that predicts juice fires the neurons, not the juice.
  • Wanting is not liking: dopamine drives the pull; small opioid hot spots make the pleasure.
  • 59–66 days: median time for a habit to become automatic, with a 4 to 335 day range.

The popular version, where every like or sweet gives you a "dopamine hit" of pleasure, gets the job description wrong. The recordings that settled this were made in trained monkeys in the 1980s and 1990s and tied to a learning algorithm from computer science in a 1997 paper in Science by Wolfram Schultz, Peter Dayan and Read Montague.

Once you see what the signal actually encodes, three everyday puzzles make sense:

  1. why the notification sound pulls harder than the message;
  2. why a habit feels automatic after a few months;
  3. why "dopamine detox" is the wrong fix for the right problem.
55–80%of midbrain dopamine neurons show the same phasic reward response (Schultz 1997)
>1 safter the cue, the dip arrives exactly when an expected reward fails to come
59–66 daysmedian time to habit automaticity across studies (Singh 2024)
4–335 daysindividual range in the same review

What does dopamine actually signal?

Dopamine neurons in the ventral tegmental area and substantia nigra signal surprise about reward, not reward itself.

The story

Wolfram Schultz trained in medicine, and when he set up his own laboratory at the University of Fribourg in Switzerland in 1977 he chose dopamine neurons because of Parkinson's disease: he wanted his work to connect to something that goes wrong in human brains. The plan was to find how these cells drive movement. His team did find some movement-related activity, but by his own account it was not very satisfying.

So they kept recording from macaques and refining the behavioural tests. What stood out was the reward. When a monkey got fruit juice, the dopamine cells fired, and the pattern shifted as the animal learned which cues predicted it. Schultz later recalled that at first the team could not believe the signal and suspected a mistake, which is why they went on to check other brain areas. The finding won him a share of the 2018 Gruber Neuroscience Prize.

Gruber Foundation, Yale: Wolfram Schultz, 2018 Neuroscience Prize
1977Schultz sets up his Fribourg laboratory
55-80%of dopamine neurons share the reward response
>1 safter the cue, the dip for a missing reward
2018Gruber Neuroscience Prize

The juice, the light and the missing juice

In the experiments Schultz summarised, a drop of fruit juice delivered without warning made most dopamine neurons fire a short burst. After a light was paired with the juice over several days of training, the juice alone no longer produced a burst. The light did.

The third condition is the decisive one. On trials where the light came on but the juice never arrived, the same neurons fell silent below their normal background rate, and the dip landed at the precise moment the juice should have appeared, more than a second after the light.

A pleasure chemical cannot fall silent at the exact moment a reward fails to arrive. A forecasting system can.Why the omission trial settled the question

Three lines and one number

Schultz, Dayan and Montague put it in three lines:

  • a positive signal when an event is better than predicted;
  • no signal when it matches;
  • a negative signal when it is worse.

They also note that the response is homogeneous: different dopamine neurons respond alike, and an apple morsel and a juice drop produce similar bursts. Aversive events such as an air puff do not produce the burst.

That uniformity is what lets one small population of cells broadcast a single "better or worse than expected" number to the striatum, the nucleus accumbens and the frontal cortex.

Dopamine neuron output (schematic after Schultz, Dayan & Montague 1997) 1. No prediction, reward arrives: burst at reward 2. Cue predicts reward, reward arrives: burst moves to cue 3. Cue predicts reward, reward omitted: dip at expected time cue reward reward no reward
The three panels of the classic experiment, redrawn as a schematic. The shape, not the exact spike counts, is what matters: the signal tracks the error in the forecast.
ConditionWhat the animal expectsWhat happensDopamine responsePrediction error
Before learningNothingJuice arrivesBurst at juicePositive
After learningJuice after the lightJuice arrives on timeBurst at light, none at juiceZero at juice
After learning, error trialJuice after the lightNo juiceBurst at light, dip below baseline at expected timeNegative
Unexpected bonusSmall rewardLarger rewardBurst (better than predicted)Positive
A Neural Substrate of Prediction and RewardWolfram Schultz, Peter Dayan, P. Read Montague · Science 275 · 1997

The paper reviews single-neuron recordings from midbrain dopamine cells in alert monkeys doing simple conditioning tasks, and shows that their firing matches the temporal difference (TD) error from reinforcement learning. Before training, juice triggers a burst; after several days of light-then-juice pairings the burst moves to the light; when the juice is withheld, firing drops below baseline at the expected moment, more than a second after the cue. The phasic response appears in 55 to 80% of dopamine neurons. The limit: these are trained animals in tightly timed lab tasks, and later work shows dopamine also carries signals about movement, novelty and salience that a pure TD account does not cover.

Read the paper (free)

Why does a prediction error teach the brain anything?

A prediction error is useful because it says exactly how much to adjust. The temporal difference rule that Richard Sutton and Andrew Barto brought into psychology in the early 1980s defines the error at each moment as the reward just received, plus the discounted value of the next state, minus the value you predicted for the current state:

\[ \delta_t = r_t + \gamma V(s_{t+1}) - V(s_t) \]
  • If \( \delta \) is positive, the weights linking the current cues to value go up.
  • If it is negative, they go down.
  • If it is zero, nothing changes, because nothing new was learned.

Why value creeps backwards to the cue

The clever part is the "next state" term. The brain does not have to wait for the juice to know it was right; the moment a reliable cue appears, the value of the whole situation jumps, and that jump is itself an error that can teach the step before it.

Run the loop for long enough and value propagates backwards through a chain of cues: from juice to light, from light to the sound that precedes the light. That backward creep is why the dopamine burst migrates to the earliest reliable predictor, and why your hand reaches for the phone at the buzz before you have read anything.

Value creeps back to the earliest cueBuzzUnlockMessageEarly pairingsburst hereAfter learningburst hereflat if predictedTD error moves back
The same shift Schultz recorded with a light and juice, drawn on a phone notification. Once the buzz reliably predicts something, the buzz carries the signal and a fully predicted message adds little. Schematic, not measured data.

The same family of algorithms, temporal difference reinforcement learning, is still used to train artificial agents, which is part of why neuroscientists treat the 1997 match as one of the field's strongest theory-to-data links. The debate since then is about scope, not about whether the error signal exists.

Use this to check what you just read. It runs the simplest version of the update, \( V \leftarrow V + \alpha\,\delta \), for the same reward on every trial, so you can watch the error shrink as the forecast catches up.

Watch a prediction error shrink with practice

Diagram of the human brain showing the substantia nigra and ventral tegmental area projecting to the striatum and prefrontal cortex
The reward circuit in outline: dopamine cells in the substantia nigra and ventral tegmental area send their axons to the striatum and frontal cortex, the targets that receive the error signal.Photo: Oscar Arias-Carrión1, Maria Stamelou, Eric Murillo-Rodríguez, Manuel Menéndez-González and Ernst Pöppel., CC BY 2.0, via Wikimedia Commons

How does that signal turn actions into habits?

Habits form when the dopamine-driven learning moves control from deliberate, goal-directed choice to cue-triggered responding in the dorsal striatum. Henry Yin and Barbara Knowlton's 2006 review in Nature Reviews Neuroscience lays out the distinction used in animal work:

TestGoal-directed actionHabit
Outcome is devaluedResponding fallsResponding largely continues
What drives itExpectation of the outcomeThe preceding stimulus (cue)
Main striatal regionDorsomedial (associative)Dorsolateral (sensorimotor)

How the error does the training

Nineteenth-century line drawing of a cross-section through the human brain at the level of the corpus striatum, the striped structures deep in each hemisphere
An 1890 drawing of a slice through the human brain at the striatum (the "striped bodies"). The dorsolateral part of this structure is where cue-triggered habits end up, and dopamine is its teaching signal.Photo: Meyer Ch., Public domain, via Wikimedia Commons

Every time a cue, an action and a reward line up, the cue-action link gets strengthened. Early on the reward is surprising, the error is large and learning is fast.

As the reward becomes fully predicted, the error at the reward shrinks to zero, yet the behaviour does not fade, because by then the cue carries the value and the striatal circuit fires the routine on sight of it. This is why a mature habit feels effortless and joyless at the same time: you are no longer learning, you are executing.

The human habit curve

It also explains the shape of the habit curve in humans. In Phillippa Lally's 2010 study at University College London, 96 volunteers chose one eating, drinking or exercise behaviour to repeat daily in the same context for 12 weeks; 82 finished.

Automaticity rose steeply in the first weeks and then flattened, the asymptotic curve you would expect from an error signal that shrinks as prediction improves. Missing one day did not reset progress.

96volunteers chose a daily habit (Lally 2010)
82finished the 12 weeks
12 weeksof daily repetition in the same context
66 daysmedian time to automaticity
How long habits take to become automatic
See the data as a table
Days to automaticity (days)
Lally 2010: fastest participant18
Singh 2024: lowest study median59
Lally 2010: typical (median)66
Singh 2024: lowest study mean106
Singh 2024: highest study mean154
Lally 2010: slowest (extrapolated)254
Singh 2024: longest individual335

Source: Singh et al., Healthcare 2024; Lally et al., Eur J Soc Psychol 2010 (via BPS Research Digest) · The 254-day figure is an extrapolation; Lally's study ran 84 days.

Time to Form a Habit: A Systematic Review and Meta-Analysis of Health Behaviour Habit Formation and Its DeterminantsBen Singh, Andrew Murphy, Carol Maher, Ashleigh E. Smith · Healthcare 12(23) · 2024

The University of South Australia team pooled 20 intervention studies with 2,601 participants (mean ages 21.5 to 73.5) covering physical activity, diet, flossing, drinking water and similar behaviours. Four studies reported time to automaticity: medians of 59 to 66 days, means of 106 to 154 days, and individual times from 4 to 335 days. Habit strength rose with a standardised mean difference of 0.69 (95% CI 0.49 to 0.88). Morning routines and self-chosen habits grew stronger. The limit: 11 of the 20 studies had a high risk of bias, and almost all rely on self-reported automaticity scales.

Read the paper (free)

If dopamine is not pleasure, what makes things feel good?

Pleasure and desire run on partly separate circuits, and dopamine belongs mainly to desire. Kent Berridge and Morten Kringelbach's 2015 review in Neuron separates "wanting", the motivational pull toward a reward, from "liking", the felt pleasure of getting it.

Wanting is generated by a large, distributed system in which mesolimbic dopamine plays a big part. Liking comes from a much smaller set of hedonic hot spots, each about a cubic millimetre in rats, in the nucleus accumbens, the ventral pallidum and the brainstem parabrachial nucleus. Mu-opioid stimulation inside the accumbens hot spot can at least double the 'liking' reactions rats show to sucrose.

Evidence that dopamine is not the pleasure

The review goes further: some of the best-known textbook candidates for pleasure, including the classic "pleasure electrodes" of the 1950s and the mesolimbic dopamine system, may not generate pleasure at all. Two lines of evidence:

  • raising dopamine in the accumbens increases how hard animals work for sweet rewards without increasing their liking reactions;
  • Parkinson's patients with heavy dopamine loss still rate sweet tastes as normally pleasant.
~1 mm³size of a "liking" hot spot in rats
2xopioid stimulation can at least double liking reactions
3 sitesaccumbens, ventral pallidum, brainstem
Parkinson'spatients still rate sweet tastes as pleasant

In daily life this is the gap you notice when you crave the scroll and do not enjoy it. The cue keeps its wanting value long after the liking has gone flat.

FeatureWanting (incentive salience)Liking (hedonic impact)
Main chemistryMesolimbic dopamineOpioid, endocannabinoid and orexin signalling in hot spots
Size of systemLarge and distributedSmall, specific hot spots
What it doesMakes cues attractive and drives effortMakes the reward itself feel good
After a habit formsStays high for the cueCan fade with repetition
Pleasure Systems in the BrainKent C. Berridge, Morten L. Kringelbach · Neuron 86(3) · 2015

A review of animal and human neuroimaging work on pleasure. It concludes that diverse pleasures, from food to music to money, activate surprisingly similar circuitry, that wanting is produced by a large brain system while liking comes from a few hedonic hot spots, and that mesolimbic dopamine is a poor candidate for generating pleasure itself. The limit: most of the causal evidence on hot spots comes from rodent microinjection and taste-reactivity studies, and mapping those findings onto human feelings still relies on imaging correlations.

Read the paper (free)

Why can you scroll for hours but not study for twenty minutes?

Feeds are built on variable, unpredictable rewards, which is exactly the schedule that keeps prediction errors alive. A post is sometimes great, sometimes dull, and the refresh costs one thumb movement.

Because the outcome never becomes fully predicted, each pull can still produce a positive error, and the cue (the app icon, the red badge, the buzz) gathers strong wanting value. Study is the opposite schedule: the effort is up front, the payoff is weeks away and uncertain, and nothing in the first ten minutes beats your forecast.

An interest problem, not a focus problem

A popular May 2024 thread on r/getdisciplined put it as an interest problem rather than a focus problem, since the same person can concentrate fine on a game. The prediction error account backs that up.

Attention is not broken; it is being allocated by a learning system that has been trained, very efficiently, on a different reward schedule. The fix is to change the schedule and the cues, not to starve the chemical. I cover the practical side in why you can scroll but can't study, and the cost of jumping between the two in attention residue and task switching.

Does a dopamine detox work?

Not in the way the name promises. You cannot lower your baseline dopamine by skipping your phone for a day, and dopamine is not a stock that runs out and refills.

What a "detox" can do is break the cue-response link for a while: no phone in the room means no buzz, no badge, no trigger, so the habit loop has nothing to fire on. That is a cue-control strategy, and cue control is one of the better-supported habit tools. The confused name is the problem, not the behaviour.

Why the first days feel worse

The prediction error model adds a second, less obvious point. When you remove a reliably rewarding cue, you get negative prediction errors at the expected times, the same below-baseline dip Schultz recorded when the juice failed to come.

That is felt as restlessness and craving, and it fades only as the forecast updates. So the first days of cutting back feel worse than the steady state, which is useful to know before you judge whether it is working. The full evidence review is in does dopamine detox work.

What does this mean for building a habit?

It means designing for the learning signal rather than for motivation. A context-stable cue gives the error something to attach to. Early, reliable reward makes the first repetitions teach fast.

Repetition over roughly two months moves the behaviour into the cue-driven system, with large differences between people, which is why a fixed "21 days" promise fails so many of them. The 2024 review also found morning routines and self-chosen habits grew stronger, which fits: a morning slot is a stable context, and a habit you chose carries more wanting from the start.

59-66 daysmedian time to automaticity
4-335 daysindividual range in the review
Morningroutines grew stronger
Self-chosenhabits grew stronger
  • Cue: one specific trigger, same place and time. Vague intentions give the striatum nothing to learn.
  • Routine: start smaller than feels necessary; the error signal rewards completion, not ambition.
  • Reward: make it immediate. A delayed payoff (fitness in six months) teaches almost nothing on day one.
  • Patience: expect a median near two months, and treat a missed day as noise, as Lally's data show.

For a ranked list of habit methods by evidence, see habit techniques ranked by evidence, and for a step-by-step plan, how to build a habit that lasts. The wider Manthan world, where these posts sit, is at Manthan.

Questions people ask

Is dopamine the pleasure chemical?

No. Dopamine mainly signals reward prediction error and drives wanting, the pull toward a reward. The felt pleasure, liking, comes from small hedonic hot spots driven by opioid, endocannabinoid and orexin signalling. Raising dopamine makes animals work harder for sugar without making them like it more.

Why do I get a rush from the notification, not the message?

Because the notification is the earliest reliable predictor of a possible reward. After repeated pairings, the dopamine response moves from the reward to the cue that predicts it, exactly as Schultz recorded when the burst moved from juice to the light. The message itself is often already predicted, so it produces little or no error.

How long does it really take to form a habit?

The best current estimate is a median of about 59 to 66 days, with individual times from 4 to 335 days, according to the 2024 systematic review by Singh and colleagues. The popular 21-day figure has no support in these studies, and the type of habit, its timing and whether you chose it all change the speed.

Does dopamine fasting reset your brain?

It does not reset dopamine levels. What helps is removing cues so the habit loop has no trigger, and enduring the short period of negative prediction errors, felt as craving, while your forecasts update. Treat it as cue control, not as a chemical cleanse.

Sources

  1. Schultz W, Dayan P, Montague PR. A neural substrate of prediction and reward. Science 275:1593-1599 (1997)
  2. Singh B, Murphy A, Maher C, Smith AE. Time to form a habit: a systematic review and meta-analysis. Healthcare 12(23):2488 (2024)
  3. Berridge KC, Kringelbach ML. Pleasure systems in the brain. Neuron 86(3):646-664 (2015)
  4. Yin HH, Knowlton BJ. The role of the basal ganglia in habit formation. Nature Reviews Neuroscience 7:464-476 (2006)
  5. Lally P, van Jaarsveld CHM, Potts HWW, Wardle J. How are habits formed: modelling habit formation in the real world. European Journal of Social Psychology 40:998-1009 (2010)
  6. British Psychological Society Research Digest: How to form a habit (summary of Lally et al.) (2009)
  7. Gruber Foundation, Yale University: Wolfram Schultz, 2018 Gruber Neuroscience Prize (his account of the discovery) (2018)
  8. The Transmitter: Reward learning algorithm hardwired into dopamine circuit (2026)
  9. PsyPost: A new dual-process theory solves the mystery of dopamine ramps (2026)
  10. Reddit r/Neuropsychology: Does dopamine detox work? (2024)
dopaminereward prediction errorhabit formationtemporal difference learningWolfram Schultzstriatumwanting vs liking
Sapta

Sapta (Saptarshi Sarkar) is a mechanical engineer turned marketer in Bengaluru and a solo touring rider. He writes the seven Saptaverse blogs. Work with him or read more of Mindblog.

Keep reading in Mindblog

From the other blogs