← SciSim / Neuroscience
· · SciSim ·

STDP — Spike-Timing Dependent Plasticity

🧠 Tier: Standard Undergraduate · Hebbian Learning · Neuromorphic AI
Version:
§ 01
Interactive Simulation — STDP Learning Rule
Mean weight
0.500
LTP events
0
LTD events
0
A+ integral
0.200
A− integral
0.240
Net bias
LTD
Sim Time
0
ms
Playback
STDP Preset
STDP Parameters
A+ (LTP amplitude)0.0100
A− (LTD amplitude)0.0120
τ+ LTP window (ms)20
τ− LTD window (ms)20
Pre rate (Hz)20
Post rate (Hz)20
w₀ initial weight0.500
T sim (ms)2000
Overlays
§ 02
The Idea, Step by Step
▸ From everyday timing to the STDP rule
START — Who fired first?
Picture two friends, A and B. If A always shouts just before B, you'd bet A is cueing B, and you'd trust that link more. If A only ever shouts just after B, then A clearly didn't cause B, and you'd trust the link less. Synapses in the brain do exactly this: a connection grows stronger when the input neuron fires just before the output neuron, and weaker when it fires just after. That ordering — not mere togetherness — is the heart of spike-timing-dependent plasticity (STDP).
BUILD — Put a number on the gap
The key quantity is the timing gap $\Delta t = t_{\text{post}} - t_{\text{pre}}$: how long after the input spike the output neuron fires. A small positive $\Delta t$ strengthens the synapse (LTP, long-term potentiation); a negative one weakens it (LTD). The change fades the longer the gap, following an exponential. The simplest form is $\Delta w = A_+\,e^{-\Delta t/\tau_+}$ for $\Delta t>0$. With $A_+=0.01$ and $\tau_+=20$ ms, a 3 ms gap gives $\Delta w = 0.01\,e^{-3/20}\approx +0.0086$ — a small boost. A 40 ms gap gives only $0.01\,e^{-2}\approx +0.0014$: too slow to count as causal.
DEEPEN — The full rule and the sliders
Precisely, STDP is two exponentials glued at $\Delta t=0$: LTP $A_+e^{-\Delta t/\tau_+}$ for $\Delta t>0$, and LTD $-A_-e^{+\Delta t/\tau_-}$ for $\Delta t<0$. Real neurons don't store every spike pair — each spike leaves a decaying trace, and the weight nudges whenever a partner spike arrives. Averaged over random Poisson firing, the drift is $\langle\Delta w\rangle = \nu_{\text{pre}}\,\nu_{\text{post}}\,(A_+\tau_+ - A_-\tau_-)$. Making $A_-\tau_- > A_+\tau_+$ (here $0.24>0.20$) lets noise gently depress synapses, so only well-timed, genuinely causal pairs survive. The sliders map straight onto the math: $A_+,A_-$ set the heights, $\tau_+,\tau_-$ the widths of the window, and the pre/post rates set $\nu$.
TRY THIS — In the sim above
(1) On the STDP Curve tab, slide $\tau_+$ up and watch the LTP side widen, so even late inputs still strengthen. (2) On Weight Evolution, set $A_+ = A_-$ with $\tau_+ = \tau_-$: the weight now wanders randomly instead of settling — that is why a depressive bias is needed. (3) Switch the preset to Anti-Hebbian and watch the curve flip, so now firing first weakens the link.
§ 03
Equation Derivation
▸ STDP — Biphasic Weight Update Rule
$$\Delta w(\Delta t) = \begin{cases}A_+\,e^{-\Delta t/\tau_+} & \Delta t = t_{\text{post}}-t_{\text{pre}} > 0 \;\text{(LTP)} \\ -A_-\,e^{+\Delta t/\tau_-} & \Delta t < 0 \;\text{(LTD)}\end{cases}$$

Online trace-based implementation — O(1) per spike:

$$\frac{dx_{\text{pre}}}{dt} = -\frac{x_{\text{pre}}}{\tau_+} + \sum_j \delta(t-t_j^{\text{pre}}), \quad \Delta w = A_+ x_{\text{pre}} \text{ at each post spike}$$ $$\frac{dx_{\text{post}}}{dt} = -\frac{x_{\text{post}}}{\tau_-} + \sum_k \delta(t-t_k^{\text{post}}), \quad \Delta w = -A_- x_{\text{post}} \text{ at each pre spike}$$

Mean weight change for independent Poisson inputs at rates ν_pre, ν_post:

$$\langle \Delta w \rangle = \nu_{\text{pre}}\nu_{\text{post}}\bigl[A_+\tau_+ - A_-\tau_-\bigr]$$
▸ Derivation Steps
STEP 1 — Biological Origin (Bi & Poo 1998)
STDP was experimentally demonstrated in hippocampal cultures: pre before post (within ~20 ms) → LTP (up to +50% EPSP); post before pre → LTD (up to −25%). The asymmetric window implements Hebb's postulate with temporal causality — a presynaptic neuron is potentiated if it fired BEFORE (and potentially caused) the postsynaptic spike.
STEP 2 — Trace Algorithm (Biophysical Implementation)
The trace x_pre jumps by 1 at each pre spike and decays exponentially. At each post spike, w += A+ × x_pre. This is biologically plausible: x_pre models the intracellular calcium concentration triggered by NMDA receptor activation when pre-release occurs just before backpropagating post-spike. The trace correctly handles multiple spike pairings with O(1) memory per synapse.
STEP 3 — Weight Bounds: Soft vs Hard
Hard bounds: clip w to [0, wmax]. Produces bimodal weight distribution (weights cluster at 0 or wmax). Soft (multiplicative) bounds: ΔwLTP = A+(wmax − w) × x_pre; ΔwLTD = −A− × w × x_post. Produces unimodal weight distribution, weight-normalising. Soft bounds are more biologically realistic and prevent runaway potentiation.
STEP 4 — Stability Condition: A−τ− > A+τ+
For random (uncorrelated) Poisson inputs: mean weight change = ν² × (A+τ+ − A−τ−). Setting A−τ− slightly > A+τ+ creates a net depressive bias for uncorrelated inputs — only strongly correlated (causal) spike pairs cause net potentiation. Standard parameters: A+τ+ = 0.01×20 = 0.2 vs A−τ− = 0.012×20 = 0.24. Net bias = −0.04 per pairwise interaction unit.
STEP 5 — Reward-Modulated STDP (R-STDP)
Three-factor rule: Δw = d(t) × eligibility trace, where d(t) is a dopamine/reward signal. The eligibility trace is the standard STDP kernel stored in a slow decaying memory. Synapses that were active before reward are potentiated; those active without reward are depressed. Implemented in Intel Loihi and enables unsupervised reinforcement learning without gradient computation.

▸ Worked Example — STDP Weight Update

A+ = 0.01, A− = 0.012, τ+ = τ− = 20 ms. Pre fires at t_pre = 10 ms, post at t_post = 13 ms, w₀ = 0.5.

$$\Delta t = 13 - 10 = +3 \text{ ms} > 0 \;\Rightarrow\; \text{LTP: } \Delta w = 0.01 \times e^{-3/20} = 0.01 \times 0.861 = +0.00861$$ $$w_{\text{new}} = 0.5 + 0.00861 = 0.5086$$

Now post fires at t = 7 ms (before pre at 10 ms): Δt = −3 ms → LTD: Δw = −0.012 × e^{−3/20} = −0.0103, w = 0.4983. Net for random pairings: slight depression (A−τ− > A+τ+). Only correlated inputs (pre reliably before post) cause net weight increase.

▸ References
[BP98]Bi & Poo — Synaptic modifications in cultured hippocampal neurons, J. Neurosci. 18:10464, 1998
[AN00]Abbott & Nelson — Synaptic plasticity: taming the beast, Nat. Neurosci. 3(suppl):1178, 2000
[Ger14]Gerstner et al. — Neuronal Dynamics, Cambridge, 2014. Ch. 19. Free: neuronaldynamics.epfl.ch
[PG06]Pfister & Gerstner — Triplets of spikes in a model of STDP, J. Neurosci. 26:9673, 2006
§ 04
Frequently Asked Questions
🧠 ConceptualIs STDP the same as Hebbian learning?
STDP is a causal refinement of Hebb's rule. Hebb proposed that any correlation between pre and post strengthens the synapse. STDP strengthens the synapse only when pre fires BEFORE post (Δt > 0). When post fires before pre (Δt < 0), STDP depresses the synapse — the opposite of naive Hebb. Two neurons firing simultaneously (Δt = 0) experience near-zero net change. STDP detects the direction of causality, not just co-occurrence. This allows STDP to learn directed temporal sequences, which simple Hebb rules cannot do.
Key takeaway: STDP = causal temporal specificity; Hebb = mere correlation. STDP's asymmetric window is what enables sequence learning and directional synaptic coding.
🌍 AppliedHow is STDP implemented in neuromorphic hardware for on-chip learning?
All major neuromorphic chips implement STDP: Intel Loihi 2 (programmable learning rule engine), SpiNNaker (soft STDP in real-time), IBM TrueNorth (simplified STDP). The hardware uses the trace algorithm: a pre-trace register decrements each clock cycle and resets to max at each pre spike; at each post spike, weight register increments by A+ × pre_trace. This requires only 2 trace registers + 1 weight register per synapse — extremely area-efficient. Loihi's programmable engine allows R-STDP (reward-modulated), BCM, and eligibility-trace rules for reinforcement learning.
Key takeaway: STDP in hardware = 3 registers + 2 comparators per synapse. On-chip learning without sending data off-chip — critical for edge AI and implantable BCIs.
🔬 SimulationWhat does the Weight Evolution tab show, and why does weight drift depend on firing rates?
The Weight Evolution tab shows w(t) for a single synapse driven by Poisson pre/post spike trains. Long-term drift: Δw/dt = ν_pre × ν_post × (A+τ+ − A−τ−). If A−τ− > A+τ+ (standard: 0.012×20 = 0.24 > 0.01×20 = 0.2), uncorrelated inputs produce net LTD. Only when pre reliably fires before post does LTP dominate. Increase both rates simultaneously and watch the weight evolve — at low rates, random pairing causes slow LTD drift; at high correlated rates, LTP wins.
Key takeaway: Weight drift = ν² × (LTP integral − LTD integral). The asymmetry A−τ− > A+τ+ ensures that noise causes depression; only genuine pre→post correlations cause potentiation.
💡 Non-ObviousWhy does STDP produce sharp place-field representations in hippocampus?
As an animal moves through space, hippocampal place cells fire in sequences — cell A before cell B as the animal moves A→B. This sequential firing means A is pre-synaptic to B in time (Δt > 0), so STDP potentiates A→B. Over many traversals, STDP builds a chain of potentiated synapses encoding the trajectory. Later, starting at A, this chain drives the sequence A→B→C — neural basis of episodic memory and prospective planning. Symmetric Hebb would strengthen both A→B and B→A equally, eliminating the directional map.
Key takeaway: STDP converts temporal firing sequences into spatial synaptic weight maps — the neural basis of sequential memory and trajectory coding in hippocampus.
📐 ComputationalWhy must STDP use online traces rather than stored spike histories?
Storing full spike histories is O(N_spikes²) per synapse — intractable for large networks. The trace algorithm is O(1) per spike: only one trace value per synapse is stored and decremented each timestep. The trace also correctly handles multiple pairings: when two pre spikes precede one post spike, the trace x_pre at post-spike time correctly reflects both contributions (exponentially weighted). Naive pairwise summation double-counts or misses near-simultaneous spikes. The trace maps directly onto the calcium dynamics that underlie LTP/LTD biophysically.
Key takeaway: Traces: O(1) per spike vs O(N²) for history. Traces correctly handle multiple pairings via exponential integration — matching the biophysical calcium kinetics.
🎓 DeepWhat is the connection between STDP and Bayesian causal inference?
STDP can be derived as an approximation to online Bayesian inference about causal relationships (Pfister & Gerstner, 2006). If the brain computes the posterior probability that a presynaptic neuron caused a postsynaptic spike, the optimal Bayesian update has the same mathematical form as the STDP rule — with τ+, τ− corresponding to the prior belief about how long causal influences last. The triphasic STDP rule (additional long-timescale LTP component) is derivable from a minimum-variance estimator. This gives principled theoretical justification: STDP is what an optimal Bayesian brain should compute to track causal input-output relationships from spike timing alone.
Key takeaway: STDP is not just empirical — it can be derived as optimal Bayesian causal inference from spike timing. The time constants encode the brain's prior about causal influence duration.
🧠 ConceptualWhy must A− be slightly greater than A+ for STDP to be stable?
With random (uncorrelated) Poisson inputs, a synapse experiences roughly equal numbers of LTP and LTD events. If A+ = A−, the weight performs a random walk — it will eventually hit 0 or wmax due to diffusion (bimodal distribution). If A+ > A−, random inputs cause net potentiation → all weights drift to wmax → the neuron loses selectivity (runaway potentiation). Setting A− slightly > A+ creates a net depressive bias for uncorrelated inputs: Σ LTD > Σ LTP for random timing. Only genuine correlated (causal) spike pairs produce net LTP and weight increase. This makes STDP a selectivity filter: it strengthens only causally informative synapses.
Key takeaway: A−τ− > A+τ+ ensures uncorrelated noise causes net depression. Only genuinely causal (pre before post) correlations can cause net potentiation — STDP becomes a causal correlation filter.
§ 04 Best Resources
§ 05
Misconceptions & Common Errors
Sub-block A — Conceptual Misconceptions
"STDP potentiates every active synapse when the postsynaptic neuron fires."
Only synapses where the presynaptic neuron fired BEFORE the postsynaptic neuron (within τ+ ms) are potentiated. Synapses where pre fired AFTER post are depressed. Synapses outside the STDP window (|Δt| > ~3τ) are unaffected. STDP is a causal and temporal specificity rule — it does not uniformly strengthen all active synapses, only those that may have contributed to the firing in the correct temporal order.
📖 Bi & Poo (1998); Gerstner et al. — Neuronal Dynamics Ch. 19
"Setting A+ = A− makes STDP stable — equal LTP and LTD amplitudes prevent weight drift."
Equal amplitudes with equal time constants give zero mean drift for uncorrelated inputs — but nonzero variance. The weight performs a random walk that eventually hits 0 or wmax (hard bounds), producing bimodal distribution. For stability, A−τ− must exceed A+τ+, creating net depression for random inputs. Without this bias, all synapses drift to extremes, eliminating selectivity. Soft (multiplicative) bounds are more effective at producing stable unimodal weight distributions.
📖 Abbott & Nelson (2000) Nat. Neurosci. 3(suppl)
"The τ+ and τ− windows are always equal and symmetric around Δt=0."
STDP windows vary significantly across synapse types and brain regions. In Bi & Poo hippocampal synapses, τ+ ≈ τ− ≈ 20 ms, but A+ ≠ A−. In some cortical synapses, the LTD window is much broader (τ− > 50 ms). Cerebellar parallel fibre→Purkinje synapses show anti-Hebbian STDP (opposite sign). Cortical L5 pyramidal synapses can show triphasic windows. The window shape depends on NMDA receptor kinetics (LTP), endocannabinoid signalling (some LTD), and neuromodulatory context. Never assume symmetric windows without checking the specific synapse type.
📖 Dan & Poo (2004) Neuron 44:23; Pfister & Gerstner (2006)
Sub-block B — Numerical Errors
Implementing STDP by summing all spike pairs at the end: for pre in spikes: for post in spikes: dw += A*exp(-|dt|/tau)
Use the online trace algorithm. The all-pairs sum overcounts: if two pre spikes precede one post spike, both should contribute, but naive pairwise summing treats them as fully independent. The trace correctly combines multiple pre spikes: x_pre at the post spike time reflects the exponential sum of all prior pre spikes, weighted by recency. Hard reset (x_pre → 0 after contributing) = nearest-neighbour rule; no reset = all-pairs rule. Choose based on the biological protocol being modelled.
🔍 Why: The STDP formula is defined for a single pair; multiple-pair extension requires the trace algorithm to avoid double-counting.
Not clamping weights after updates: weights become negative or exceed wmax.
Always clip weights: w = Math.max(0, Math.min(wmax, w + dw)). For soft (multiplicative) bounds: dw_LTP = A+ × (wmax − w) × x_pre; dw_LTD = −A− × w × x_post. Soft bounds automatically prevent w from exceeding [0, wmax] by making the update proportional to the remaining room. Hard bounds are simpler; soft bounds produce unimodal weight distributions that better match biology. This is the most common STDP implementation bug — always verify weight bounds after each step.
🔍 Why: STDP updates are additive and unbounded; without explicit clamping, weights diverge to unphysical values.
§ 05 References