AnyLearn
All lessons
Scienceadvanced

How the Brain Computes: Prediction, Reward, and an Energy Budget

What brains compute and how theory meets data. Covers Marr's levels, dopamine as a reward prediction error with a working TD-learning model, predictive coding, Bayesian cue combination, the brain's energy budget, and an honest comparison with artificial neural networks, separating established findings from contested theories.

Updated · AI-authored, review-gated · how lessons are made

Progress1 / 10

What it means to say a brain computes

The previous lessons in this path built the parts: spikes, synapses, plasticity, and circuits. To ask what the parts are for, neuroscience still leans on a framework David Marr laid out in his book Vision (1982). Any information-processing system can be described at three levels:

LevelQuestionExample for reward learning
ComputationalWhat problem is solved, and why?Predict future reward to choose good actions
AlgorithmicWhat representation and procedure?Temporal-difference learning with an error signal
ImplementationalWhat physical machinery?Dopamine neurons and plasticity at striatal synapses

The levels constrain each other without determining each other. Many algorithms solve one problem, and one algorithm can run on many substrates.

Key idea: The most productive results in computational neuroscience connect all three levels at once. Reward prediction error, next, is the textbook case, which is why it gets the most space in this lesson.

Sign in free to save your progress and earn certificates.

Full lesson text

All 10 steps on one page, for reading, reference, and search.

Show

1. What it means to say a brain computes

The previous lessons in this path built the parts: spikes, synapses, plasticity, and circuits. To ask what the parts are for, neuroscience still leans on a framework David Marr laid out in his book Vision (1982). Any information-processing system can be described at three levels:

LevelQuestionExample for reward learning
ComputationalWhat problem is solved, and why?Predict future reward to choose good actions
AlgorithmicWhat representation and procedure?Temporal-difference learning with an error signal
ImplementationalWhat physical machinery?Dopamine neurons and plasticity at striatal synapses

The levels constrain each other without determining each other. Many algorithms solve one problem, and one algorithm can run on many substrates.

Key idea: The most productive results in computational neuroscience connect all three levels at once. Reward prediction error, next, is the textbook case, which is why it gets the most space in this lesson.

2. Dopamine signals the error, not the reward

Wolfram Schultz recorded dopamine neurons in the midbrain of monkeys learning that a cue predicts a juice reward. Schultz, Dayan and Montague (1997, Science) showed the firing matched a quantity from machine learning, the temporal-difference (TD) error:

δt=rt+γV(st+1)−V(st)\delta_t = r_t + \gamma V(s_{t+1}) - V(s_t)

Here V(s)V(s) is the predicted future reward from state ss, rtr_t the reward just received, and γ\gamma a discount factor. The error is positive when things turn out better than predicted and negative when worse.

Three observations line up with the equation:

  1. Before learning, an unexpected reward produces a burst of dopamine firing.
  2. After learning, the burst moves to the cue, and the now-predicted reward produces no change.
  3. If a predicted reward is omitted, firing dips below baseline at exactly the time the reward was due.

Later work established causality: Steinberg and colleagues (2013, Nature Neuroscience) showed in rats that optogenetically stimulating dopamine neurons at the moment of reward could substitute for a positive prediction error and drive learning.

3. A TD model you can run

A minimal simulation reproduces all three dopamine observations. A trial has six time steps after a cue; reward arrives at the last one. The cue itself arrives at an unpredictable moment, so the error at cue onset is just the value the cue predicts.

import numpy as np

T, REWARD_STEP = 6, 5
alpha = 0.3                    # learning rate
V = np.zeros(T + 1)            # V[T] = 0: the trial is over

def run_trial(V, rewarded=True):
    deltas = [V[0]]            # error at cue onset: V(cue) - 0
    for t in range(T):
        r = 1.0 if (rewarded and t == REWARD_STEP) else 0.0
        d = r + V[t + 1] - V[t]  # TD error, gamma = 1
        V[t] += alpha * d
        deltas.append(d)
    return np.round(deltas, 2)

print(run_trial(V))                   # [0. 0. 0. 0. 0. 0. 1.]
for _ in range(200):
    run_trial(V)
print(run_trial(V))                   # [1. 0. 0. 0. 0. 0. 0.]
print(run_trial(V, rewarded=False))   # [ 1. 0. 0. 0. 0. 0. -1.]

The first array is the naive animal: the error sits at the reward. After 200 trials it has moved to the cue. Omitting the reward produces a negative error at the reward time, the dip Schultz recorded.

4. The reward-learning loop

A simplified view of how the prediction error is thought to drive learning. Dopamine neurons in the ventral tegmental area and substantia nigra compare received reward with predicted value and broadcast the error to the striatum and cortex, where it gates plasticity at the synapses that represent the current situation.

flowchart LR
  A["Cue or situation"] --> B["Cortex: represents the state"]
  B --> C["Striatum: predicted value"]
  C --> D["Dopamine neurons: compare"]
  E["Actual reward"] --> D
  D --> F["Prediction error broadcast"]
  F --> G["Plasticity at cortico-striatal synapses"]
  G --> C

5. Predict: when the expected reward never comes

The omission result is worth testing against intuition, because it separates a reward signal from a reward prediction error signal.

Predict first

A monkey has fully learned that a light predicts juice two seconds later. On one trial the juice is withheld. What do its dopamine neurons do at the moment the juice was due, if they encode (a) reward itself, versus (b) reward prediction error?

Gotcha: The picture is richer than a single scalar error. Dabney and colleagues (2020, Nature) found that individual dopamine neurons in mice differ in how optimistic their predictions are, consistent with distributional reinforcement learning, where the population encodes a whole distribution of possible rewards. Other studies find dopamine signals tied to novelty, salience, and movement, and how these fit with the error account remains debated.

6. Predictive coding: perception as error correction

If prediction error is useful for reward, perhaps the sensory cortex uses it too. Rao and Ballard (1999, Nature Neuroscience) proposed a model of visual cortex in which higher areas send predictions down the hierarchy and lower areas send back only the error, the part of the input the prediction failed to explain. Their model reproduced known oddities of V1 neurons, such as responses that weaken when a stimulus extends beyond the receptive field.

The evidence comes in two tiers, and it matters to keep them apart:

  • Well supported: the brain produces prediction-sensitive signals. Responses shrink for repeated or expected stimuli and grow for surprising ones, and mismatch responses to an unexpected sound in a regular sequence are robust in human EEG studies.
  • Contested: that cortex is organised as a hierarchy of explicit prediction and error units throughout, and the broader free-energy principle proposed by Karl Friston (2010, Nature Reviews Neuroscience) as a unifying theory of brain function.

Gotcha: A common criticism of the most general versions is that they are flexible enough to fit almost any result, which makes them hard to falsify. Specific, testable circuit-level versions are where the active experimental work happens.

7. The Bayesian brain: weighting cues by reliability

Sensory signals are noisy, so a good perceptual system should weight each cue by how reliable it is. For two independent cues with Gaussian noise, the statistically optimal combination weights each by its inverse variance:

s^=wVsV+wHsH,wV=1/σV21/σV2+1/σH2\hat{s} = w_V s_V + w_H s_H, \qquad w_V = \frac{1/\sigma_V^2}{1/\sigma_V^2 + 1/\sigma_H^2}

Ernst and Banks (2002, Nature) tested this with people judging the height of a bar they could both see and touch. As the researchers degraded the visual signal with noise, people shifted their reliance from vision toward touch in close agreement with the optimal weights, and the combined estimate was more precise than either sense alone, as the formula predicts.

ClaimStatus
Behaviour in many perceptual tasks approximates Bayesian cue combinationWell supported
Priors learned from experience bias perception in predictable waysWell supported
Neurons explicitly represent probability distributions, and howOpen, with several competing proposals
The brain is Bayes-optimal in generalContested: many tasks show systematic suboptimality

Behaviour fitting a Bayesian model says what problem is being solved, Marr's top level. It does not by itself reveal the algorithm.

8. Computing on an energy budget

Whatever the brain computes, it does so under a severe power constraint, and the numbers are well documented:

  • The brain is about 2 percent of adult body weight but uses about 20 percent of the body's resting energy (Raichle and Gusnard, 2002, PNAS).
  • In absolute terms that is roughly 17 to 20 watts, derived from glucose uptake (Balasubramanian, 2021, PNAS).
  • Synaptic transmission takes the largest share: Harris, Jolivet and Attwell (2012, Neuron) estimated that pre- and postsynaptic mechanisms account for about 55 percent of ATP use in rat neocortex.
  • Lennie (2003, Current Biology) estimated that the cost of spikes limits the fraction of cortical neurons that can be substantially active at once to possibly fewer than 1 percent.

Key idea: Energy cost favours sparse codes, where any given stimulus activates few neurons strongly. Olshausen and Field (1996, Nature) showed that learning a sparse code for patches of natural images produces oriented, localised filters resembling V1 simple-cell receptive fields, linking an efficiency principle to the tuning Hubel and Wiesel recorded.

The often-repeated claim that people "use only 10 percent of their brain" is a misreading of this: sparse activity at any instant is not idle tissue, since different neurons are active at different times.

9. Brains and artificial neural networks

Artificial neural networks borrowed the neuron as a metaphor, and our deep learning foundations path covers them on their own terms. Comparing the two directly shows how loose the metaphor is.

DimensionBiological brainTypical artificial network
UnitNeuron with active dendrites and many channel typesWeighted sum plus a fixed nonlinearity
SignalSparse, timed spikes plus graded local voltagesDense real-valued activations
Sign of connectionsMostly fixed per neuron (Dale's principle)Any weight can be positive or negative
Learning ruleLocal plasticity gated by neuromodulatorsBackpropagation of a global error
ConnectivityHeavily recurrent, with extensive feedbackOften mostly feedforward
EnergyRoughly 20 W for the whole brain (Balasubramanian, 2021)Depends on hardware; training large models uses far more

The most debated row is learning. Backpropagation needs each synapse to know its contribution to a distant error, which no known biological mechanism delivers exactly. Lillicrap and colleagues (2020, Nature Reviews Neuroscience) reviewed proposals for how the brain might approximate it using feedback connections. Whether it does is unresolved.

10. A map of what we know

Across this path, the evidence for different claims varies enormously. A compact way to hold it:

ClaimEvidence level
Ionic mechanism of the action potential (Hodgkin and Huxley)Established, confirmed down to single channels
NMDA-dependent LTP and LTD at many synapsesEstablished
Receptive fields, place cells, grid cellsEstablished, widely replicated
Dopamine neurons signal reward prediction errorStrongly supported, with causal tests; details debated
Behaviour approximates Bayesian cue combination in many tasksWell supported at the behavioural level
Cortex implements hierarchical predictive codingContested
The brain approximates backpropagationOpen
How long-term memories are stored and retrieved across yearsPartly understood, major gaps

In practice: When you meet a confident claim about "how the brain does X", ask which of Marr's levels it addresses, which species and method the evidence comes from, and whether there is a causal manipulation or only a correlation. Those three questions place almost any result on this map.

Check your understanding

The lesson ends with a 5-question quiz. Take it in the player above to see your score.

  1. After a monkey has fully learned that a cue predicts juice, when do its dopamine neurons burst on a normal rewarded trial?
    • At the juice delivery only
    • At both the cue and the juice equally
    • Neither, because nothing is surprising
    • At the cue, with no change at the predicted juice
  2. In the TD simulation, what does the error array look like on a trial where the learned reward is omitted?
    • All zeros
    • A positive error at the cue and a negative error at the reward time
    • A negative error at the cue only
    • A positive error at the reward time
  3. In Ernst and Banks' experiment, what happened as the visual signal was made noisier?
    • People relied more on touch, in line with inverse-variance weighting
    • People ignored touch and relied only on vision
    • People averaged vision and touch equally regardless of noise
    • The combined estimate became less precise than touch alone
  4. Which statement about the brain's energy use is supported by the sources in this lesson?
    • Action potentials use most of the brain's energy, with synapses negligible
    • The brain uses about 2 percent of the body's resting energy
    • Synaptic mechanisms account for about 55 percent of ATP use in rat neocortex, per Harris, Jolivet and Attwell
    • Most cortical neurons can fire strongly at the same time without energy limits
  5. Which claim is best classified as contested rather than established?
    • Dopamine neurons dip below baseline when a predicted reward is omitted
    • Cortex is organised throughout as a hierarchy of explicit prediction and error units
    • Place cells fire at specific locations
    • The action potential depends on voltage-gated sodium and potassium channels

Related lessons

AI
advanced

Dreaming in Latent Space: World Models, PlaNet, Dreamer and MuZero

How agents learn compact latent world models from pixels and plan inside them. Covers Ha and Schmidhuber's dream-trained controller, PlaNet's recurrent state-space model, Dreamer's actor-critic in imagination with lambda-returns in code, the later Dreamer versions, and MuZero's value-equivalent model.

12 steps·~18 min
AI
intermediate

What a World Model Is, and How an Agent Plans With One

A world model is a learned simulator that predicts what happens if an agent acts. This lesson covers its parts, why model-based learning needs far less real experience, Dyna versus model-predictive control, a working planner in code, and why a planner exploits model errors.

10 steps·~15 min
Science
intermediate

Circuits and Codes: How Populations of Neurons Represent the World

How wiring motifs like lateral inhibition and recurrence turn single neurons into computing circuits, and how those circuits encode the world. Covers receptive fields and the visual hierarchy, rate, timing and population codes, place and grid cells, attractor networks, and what connectomes can and cannot tell us.

10 steps·~15 min
Science
intermediate

Synapses and Plasticity: How Neurons Talk and Learn

How a spike becomes a chemical message, how a neuron sums thousands of them, and how synapses change with experience. Covers transmitter release, excitation and inhibition, dendritic integration, Hebbian learning, LTP, the NMDA receptor as a coincidence detector, and spike-timing-dependent plasticity.

10 steps·~15 min