Computational Neuroscience Modeling
Modeling Neuronal Dynamics with a Leaky Bucket
Why modeling is useful in computational neuroscience
Modeling connects what can be measured to what researchers want to understand. Experiments often provide indirect or incomplete observations: the quantity that can be measured may differ from the underlying process that answers the scientific question. A model supplies a framework for relating the two.
For example, a researcher interested in how synaptic vesicles release neurotransmitter may not be able to measure each vesicle’s dynamics directly. Instead, the researcher can measure postsynaptic potentials (PSPs) and use a model of synaptic dynamics to infer how vesicle release may have produced the observed PSP amplitudes.
Modeling can also connect different levels of explanation:
Cellular or molecular dynamics can be related to the activity of neuronal circuits.
Circuit activity can be related to the computational functions a brain system may perform.
A model can therefore help address not only what is measured, but also how or why a system behaves as it does.
The leaky integrate-and-fire model
The leaky integrate-and-fire model is a simplified model of neuronal dynamics. It captures an important aspect of how a neuron responds to input: input accumulates over time, while some of the accumulated quantity also leaks away.
The model is simpler than more detailed neuron models, such as the Hodgkin–Huxley model. However, it can be useful when the main interest is the behavior that emerges from interactions among many neurons. In network models, a simplified description of each neuron may be sufficient if it captures the dynamics relevant to the network and is combined with an appropriate model of synapses.
To understand the model’s basic dynamics, it is helpful to begin with a leaky bucket. The bucket is an analogy: its water height plays the role of a neuron’s voltage or potential, and water flow plays the role of electrical input and leakage. The analogy produces a mathematical equation with the same general form as the neuronal model.
The leaky-bucket model
Height, input, and leakage
Consider an idealized bucket with a hole at the bottom. Water flows into the bucket from above, and water flows out through the hole.
Let:
H(t) be the height of the water at time t.
I(t) be the rate of water flowing into the bucket.
L(t) be the rate of water flowing out through the leak.
Both I(t) and L(t) are flow rates, so they have units of volume per time, such as liters per second.
The water level changes according to the balance between inflow and outflow:
If inflow exceeds outflow, the water level rises.
If outflow exceeds inflow, the water level falls.
If the two flows match, the water level remains constant.
The net flow into the bucket is
Modeling the leak
The faster water flows out through the hole, the greater the water pressure at the bottom. A simple approximation is that the outflow is proportional to the water height:
where G is a constant describing the strength of the leak. A larger G means that more water flows out for a given height.
This is a simplified physical description. Real flow can depend on other factors, such as viscosity and turbulence, but a linear relationship is useful for understanding the model.
Relating water volume to height
Changes in net flow change the volume of water in the bucket. For a bucket with a fixed cross-sectional area, volume is proportional to height:
where C is a constant relating volume to height. For a cylindrical bucket, C is its cross-sectional area.
The rate of change of volume equals net inflow:
Substituting V(t)=CH(t) and L(t)=GH(t) gives
Dividing by G and defining the time constant
produces the leaky-bucket equation:
The time constant τ has units of time. It sets the timescale over which the water level responds to changes in input.
The model’s central idea is that the height moves toward the input-dependent level I(t)/G, while the leak continually pulls it back.
Response to a constant input
Suppose the tap is set to a fixed flow rate, so that I(t)=Iˉ, where Iˉ is constant. The equation becomes
Equilibrium height
An equilibrium is a state that does not change over time. At equilibrium, dH/dt=0, so
At this height, the outflow exactly balances the inflow:
The equilibrium is stable:
If H>Heq, the leak exceeds the inflow, so dH/dt<0 and the water level falls.
If H<Heq, the inflow exceeds the leak, so dH/dt>0 and the water level rises.
The farther the water level is from equilibrium, the stronger the tendency to move back toward it.
Exponential approach to equilibrium
Starting from height H(0), the solution for a constant input is
The exponential term e−t/τ decreases toward zero as time passes. Consequently, the initial difference between the water level and equilibrium gradually disappears, and H(t) approaches Iˉ/G.
The time constant τ controls the speed of this approach:
A small τ gives a rapid response.
A large τ gives a slower response.
The exponential approaches zero increasingly slowly and does not reach zero at any finite time. In practice, the system becomes very close to equilibrium after several time constants.
Response to a changing input: smoothing and filtering
In neuronal applications, input is usually not constant. It may change as a result of synaptic activity, incoming spikes from other neurons, or current applied through an electrode.
When I(t) varies, the water height cannot instantly reach the changing target I(t)/G. Instead, it moves toward the current target with a speed governed by τ. The height therefore lags behind the input.
This gives the model a filtering effect:
With a small time constant, the height tracks changes in input relatively closely.
With a large time constant, the height responds more slowly and follows rapid fluctuations less closely.
The output is a smoothed version of the input because short-lived changes may occur too quickly for the height to follow.
In this sense, the system averages recent input over time, with older input having progressively less influence. The smoothing timescale is set by τ. An input that changes slowly compared with τ is tracked more closely than one that changes rapidly.
This interpretation is useful even when an exact analytical solution is not practical. In a network of neurons, the input to one neuron may depend on the changing activity of other neurons, so it may not be known in advance as a simple function of time.
Numerical solution using the Euler approximation
Why use a numerical method?
For a simple constant input, the solution can be written as a formula. For more complicated, changing inputs—especially inputs generated by a network of interacting neurons—it is often more useful to calculate an approximate solution at successive points in time.
A numerical method calculates values of the solution step by step rather than expressing the entire solution as a known mathematical function.
The Euler idea
Suppose a quantity f(t) obeys a differential equation
where F(f,t) gives the rate of change of f.
Over a short time interval Δt, the Euler approximation estimates the new value using the current value and current rate of change:
The method assumes that the rate of change remains approximately constant during the short interval.
A cyclist example illustrates the idea. If a cyclist is moving at 5 meters per second, then after one second the cyclist’s position is estimated to have increased by 5 meters. This is approximate because the cyclist’s speed might change during that second. Repeating the estimate over smaller intervals and updating the speed at each step can improve the tracking.
Applying Euler’s method to the leaky bucket
Divide time into equally spaced points:
where n is the step number. Let Hn be the approximate height at time tn. Applying Euler’s method to the leaky-bucket equation gives
The calculation proceeds iteratively:
Start with a known initial height H0.
Use the current height and input to calculate H1.
Use H1 and the input at the next time step to calculate H2.
Continue to obtain approximate heights at later times.
For a neuron model, the same procedure can be applied to the corresponding differential equation, with voltage replacing water height and neuronal input replacing water flow.
Accuracy and time-step size
Euler’s method is an approximation. Its accuracy depends in part on how much the rate of change varies during each step:
A smaller Δt generally improves the approximation because the rate has less time to change within a step.
A larger Δt is computationally quicker but can produce larger errors.
Neuronal simulations may use steps on the order of a millisecond or a tenth of a millisecond, depending on how quickly the modeled activity changes. More advanced methods, including Runge–Kutta methods, use additional information about how the rate changes to improve accuracy.
Key takeaways
Models help connect observable measurements to underlying biological processes and broader questions about neural function.
A leaky bucket provides an intuitive analogy for the leaky integrate-and-fire model: input accumulates, while leakage opposes that accumulation.
The leaky-bucket equation is
τdtdH=GI(t)−H(t),where τ sets the response timescale.
With constant input, the height approaches the stable equilibrium Heq=Iˉ/G exponentially.
With changing input, the system lags behind and smooths rapid fluctuations; larger τ produces slower, stronger smoothing.
Euler’s method approximates the solution by repeatedly advancing the current value using the current rate of change.
These same dynamical ideas provide a foundation for understanding how simplified neuronal models respond to inputs and for simulating their activity over time.

Ask anything
We've read this whole study set, so questions about it get the best answers.