2. The spiking neuron (LIF)

Lesson 2 of 8 · about 15 minutes · needs only basic arithmetic · last checked November 2026

The idea

A leaky integrate-and-fire (LIF) neuron keeps one number, its membrane potential v. On every time step it does three things:

v = beta * v + input;
if (v >= threshold) {
  spike = true;
  v = 0;
}

beta is the leak: 1.0 means no leak, smaller values forget faster. This is a simplified, discrete-time form of the model used in libraries such as snnTorch, Brian2 and Nengo.

A worked example

Use the playground defaults: beta = 0.9, threshold = 1.0, input = 0.12 per step.

The potential climbs toward a steady level of input / (1 - beta), which is 0.12 / 0.1 = 1.2. That is above the threshold, so the neuron fires. Starting from zero, stepping through the formula gives the first spike on step 18. After the reset the neuron starts again from zero, so it spikes every 18 steps.

Now lower the input to 0.08. The steady level is 0.08 / 0.1 = 0.8, which is below the threshold. The neuron never fires: the leak cancels the input.

Rule of thumb: a LIF neuron can only fire if input / (1 - beta) is above the threshold. That is why spiking neurons respond to strong or sustained input and stay silent otherwise, and why silence means no work for the hardware.

Try it

Open the LIF neuron playground and check the example: the defaults give a steady rhythm of spikes, and an input of 0.08 gives none.

Exercise

Set beta = 0.8 and threshold = 1.0. What is the smallest input that lets the neuron fire? Predict it first, then test it in the playground.

Show the answer

The steady level is input / (1 - 0.8) = input / 0.2. It must be above 1.0, so the input must be above 0.2. Try 0.19 (silent) and 0.25 (fires).

Limits of this model

Real neurons are far more complex. LIF is popular because it is simple and cheap to compute, not because it is complete.

← Lesson 1Lesson 3: Encoding →