Extra model · builds on Module 4

Time cells: a memory of the ride built from EWMs

Your bike computer can show your average power over the last 3 s, the last 30 s or the last 20 min. Each of these numbers tells you how much you pushed recently. None of them tells you when. Ride 10 minutes at 300 W and then 10 minutes at 100 W, or the other way round: either way, your 20-minute average is 200 W. An exponentially weighted mean (EWM) has the same problem. Many different rides end with the same value, because one number cannot hold a timeline.

Your memory of a ride works differently. At the top of the last climb you remember the attack of two minutes ago quite precisely, the climb before it more vaguely, and the first hour as a blur. Something like this has been recorded in rats: cells in the hippocampus that respond at different delays after an event, with the late ones more spread out in time than the early ones. They are called time cells. In 2012, Karthik Shankar and Marc Howard showed how to build time cells from two things you already know from Module 4: a set of EWMs with different time constants, and a fixed table of weights that mixes neighboring EWMs.

On this page I apply their model to the power of a cyclist in a race, and then put it next to the Banister model and Workout Reserve. All three are built from the same parts.

1. A bank of EWMs

Start from the equation you know from Module 4, with power as the input:

τddtEWMτ(t)+EWMτ(t)=P(t)\tau \frac{d}{dt}EWM_\tau(t) + EWM_\tau(t) = P(t)

An EWM with a short time constantM3 forgets quickly and follows every surge. One with a long time constant forgets slowly and hardly moves. Run several at once, each with its own τ, and you have a bank. Workout Reserve does exactly this. In our paper in the European Journal of Sport Science, the bank has twelve EWMs:

τ=12 s, 30 s, 1, 2, 3, 5, 10, 20, 30 min, 1, 2, 4 h\tau = 12\text{ s},\ 30\text{ s},\ 1,\ 2,\ 3,\ 5,\ 10,\ 20,\ 30\text{ min},\ 1,\ 2,\ 4\text{ h}

(The Workout Reserve page explains how they are used.) Each time constant is roughly twice the previous one. Shankar and Howard use the same idea, usually with many more EWMs, all spaced by the same factor (log spacing). To keep the parallel simple, this page uses Workout Reserve's twelve as they are.

Shankar and Howard call their EWMs leaky integrators. Theirs are multiplied by τ, the same difference as between Banister's original form and the moving-average form in One equation, many systemsM4: it changes the size of each response but not its shape.

At any moment the bank holds N numbers, one per time constant. The fast EWMs remember the last few seconds and the slow ones the last hours, but each of them is still a single average. The timeline comes from mixing them.

2. From EWMs to time cells

You have already built one

Take Banister's form, TSB=k1 CTL−k2 ATLTSB = k_1\,CTL - k_2\,ATL: a slow EWM of the training load minus a fast one. After a single training session, CTL and ATL go up by the same amount, and then ATL fades faster. If the two weights were equal, form would start at zero, rise as fatigue fades, peak, and then slowly fade with fitness. With the 27 and 10 days of the Module 4 chart, the peak comes about 16 days after the session. Read this way, form is a detector of a session about two weeks ago. That is a time cell.

The Module 4 chart uses k2=2 k1k_2 = 2\,k_1, so fatigue wins at first: after one session, form dips below zero, crosses zero after about 11 days and peaks after about 27. The supercompensation curve is the response of a rough time cell made of two EWMs, with a fatigue dip in front.

More neighbors, sharper cells

Two EWMs give one bump, and a wide one. Shankar and Howard mix more: each time cell takes k + 1 neighboring EWMs of the bank, with weights that alternate in sign (+, −, +, …). The number k is the order of the time cell, and the more neighbors a cell mixes, the narrower its bump. One rule comes out of the math: a time cell centered on the EWM with time constant τ looks back k·τ. With k = 0 there is nothing to mix: the cell is a single EWM, and it looks at now.

On this page k = 4, so each time cell mixes five neighboring EWMs, and the cell centered on the 3-min EWM remembers best what happened 12 min ago. The choice is arbitrary. A higher k gives sharper cells but needs more EWMs, packed closer together; section 5 has the details.

Each time cell is one spreadsheet formula: a SUMPRODUCT of five weights and five neighboring EWMs. Write the weights of all the time cells in one table, one row per time cell and one column per EWM, and you have a matrix. It is mostly zeros, because each row touches only its neighbors, along the diagonal. The weights come from a formula that the mathematician Emil Post published in 1930 (see the last section). Nothing is fitted to data: the weights depend only on the time constants of the bank and on k. If you are curious, you can rebuild the table in a spreadsheet with that formula, then change the EWMs or k and see what happens.

Four things to look for in the widget below:

  1. Each row has five weights, alternating in sign, and they add up to 1. That is why a steady power reads back as itself: ride at a steady 250 W for long enough and every time cell reads 250 W.
  2. Twelve EWMs give eight time cells, looking back from 4 min to 4 h. The two EWMs at each end miss a neighbor on one side, so no time cell is centered on them.
  3. The further back a cell looks, the wider its bump. With infinitely many EWMs this would hold in exact proportion: a cell looking back 40 min would have the same shape as one looking back 4 min, stretched 10 times. This is the scale invariance of the paper's title.
  4. Twelve EWMs are few for k = 4. For this order, neighbors should be less than 1.5 times apart, and Workout Reserve's are about twice. The cells still work, but they come out lower and wider than the ideal, and peak a little late. In the replay below I complete the bank to fix this.

The bank and the matrix

Workout Reserve's twelve EWMs, mixed with k = 4. Each row of the matrix is one time cell; the chart below it shows how three of the cells respond to one short effort.

EWMs

12

Workout Reserve's, 12 s to 4 h

Order k

4

each time cell mixes 5 neighbors

Time cells

8

12 − k: the end EWMs lack neighbors

Looking back

4 min–4 h

4 × the τ of the middle EWM

The matrix: one row per time cell, one column per EWM

positive weight negative weight zeroRows: time cells, labeled by how far back they look.

Looks back 12 min = 0.01 × EWM1 min − 0.67 × EWM2 min + 2.89 × EWM3 min − 5.21 × EWM5 min + 3.97 × EWM10 minThe weights add up to 1. Hover or tap another row to read it.

Three time cells after one short effort

Looks back 4 minLooks back 12 minLooks back 40 minIdeal: infinitely many EWMs

Solid: the time cells of this bank. Dashed: the ideal shape, with infinitely many EWMs. The area under each curve is 100%: every cell sees the whole effort once, spread over time, and the further back it looks, the wider its curve. Twelve EWMs are few for k = 4, so the solid curves come out lower and wider than the dashed ones, and peak a little late.

3. Replaying a stage

Now the bank on real data. The power below belongs to one rider in stage 2 of the Coppi & Bartali 2025, from the race data I showed in Siena (slides). It was recorded every 20 s for about 4 h 20 min.

Eight time cells give only eight points, so for this replay I completed the matrix behind the scenes. The bank has 200 EWMs, log-spaced over the same range as Workout Reserve (12 s to 4 h), and the matrix keeps k = 4. Neighbors are now only 1.036 times apart, well within the limit, so the 196 time cells are close to the ideal shape and sit at almost every look-back. The model runs every second, with each 20-s power sample held constant, and the whole computation takes well under a millisecond per frame.

Move the slider or press play. In the top chart:

  • the gray line is the power, revealed as it was ridden. Once drawn, it never changes;
  • the red line, the stimulus line, is what the time cells remember at that moment, each cell plotted where it thinks the power was: now minus how far back it looks;
  • the shaded area is the stretch of the ride that the selected time cell (dotted line) is averaging. Hover or tap the chart to pick another cell.

The purple line below joins the 200 EWMs of the bank, the only numbers the model actually stores. Workout Reserve's twelve sit on the same line, marked by thin stems: they are twelve samples of the same curve. The dashed line keeps the best value each EWM has reached so far in the stage, and it only moves when an EWM beats its own best. Workout Reserve does the same thing across sessions: its EWMMAXτEWMMAX_\tau is the best value of each EWM in the athlete's history, and wherever the solid line touches the dashed one, the ratio EWMτ/EWMMAXτEWM_\tau / EWMMAX_\tau is 100%.

Replaying a stage

Coppi & Bartali 2025, stage 2, one rider, power every 20 s. The model runs every second with the matrix completed: 200 EWMs from 12 s to 4 h, k = 4. Move the slider or press play: the power is revealed as it was ridden, and the stimulus line shows what the time cells hold at that moment. Hover or tap the chart to pick a time cell.

0:00 / 0:01
Power, revealed up to nowStimulus line: what the time cells remember nowWhat the selected cell is averaging
Loading race data…

As the slider moves forward, every effort slides back with it and spreads out. Its memory is passed from cells that look back a short time to cells that look back longer and blur more, so the last few minutes stay sharp while the first hour turns into a smooth average. The shaded window keeps the same width as you play, because the selected cell is the same; what changes is the stretch of ride underneath it. Early in the stage, the cells that look furthest back are partly looking at the time before the start, when there was no power at all, so the memory drops toward zero at the left edge.

4. Banister, Workout Reserve and time cells

Side by side, the three models share the first stage: a bank of EWMs fed with a load. What changes is how many EWMs there are and how they are read out.

BanisterWorkout ReserveShankar & Howard
InputDaily training loadPower, every secondAny signal (here, power)
EWMs2 (27 and 10 days in the Module 4 chart)12, from 12 s to 4 hUsually many, log-spaced (here, Workout Reserve's 12, and 200 in the replay)
ReadoutOne row: k1 CTL−k2 ATLk_1\,CTL - k_2\,ATLEach EWM divided by the athlete's best for that τ, then the largest ratiok + 1 neighbors per row, weights alternating in sign (here k = 4)
OutputForm, one numberHow close the athlete is to a limit, and which τ sets itA blurred timeline (here, 8 time cells, and 196 in the replay)
The question it answersFitness minus fatigue, nowHow close is each time scale to its best, now?What happened, and when?

Workout Reserve: twelve EWMs, no mixing, and a max

Workout Reserve stores the same kind of numbers as the bank on this page. Each EWM is divided by the athlete's best value for that time constant, EWMMAXτEWMMAX_\tau, taken from earlier sessions. The largest of the twelve ratios says how close the athlete is to a limit, and its τ says which time scale sets that limit.

In the EJSS paper we tested this on 21 professional cyclists during an 11-day training camp. The best values came from the first ten days. On the last day the riders did about 2000 kJ of work and then a 3-min and a 12-min time trial. At the end of each trial the largest ratio was close to 100% (medians of 98.6% and 101%). In both trials the τ that set the limit was about 1 h, not 3 or 12 min. This suggests that the limit depended on the work done earlier in the session, not only on the trial itself.

In the language of this page, Workout Reserve uses the k = 0 matrix: each EWM is rescaled by the athlete's best and none is mixed with its neighbors. Then it takes the largest ratio, a step that no table of weights can do. So it never rebuilds a timeline, and it does not need one: its question is how close each time scale is to its limit right now. Time cells ask when, and for that they need the neighbors and the alternating signs.

Changing the settings

The first widget uses Workout Reserve's twelve EWMs and k = 4, two choices made to keep the parallel simple. Both can change. More EWMs, log-spaced over the same 12 s to 4 h, bring the solid curves of the first widget onto the dashed ones: that is what the replay does with 200. A higher k gives sharper time cells, but each one needs more neighbors, packed closer together, and more rows are lost at the ends of the bank. Section 5 has the formula for the weights and the rule for the spacing, enough to rebuild the matrix in a spreadsheet and try your own settings.

5. For the curious: the math behind the matrix

This section is optional. It shows where the weights and the rules above come from, in the paper's own terms.

Shankar and Howard write each EWM as a leaky integrator, L=τ⋅EWMτL = \tau \cdot EWM_\tau, with rate s=1/τs = 1/\tau:

dL(t,s)dt=−s L(t,s)+P(t)⇒L(t,s)=∫−∞tP(t′) e−s (t−t′) dt′\frac{dL(t,s)}{dt} = -s\,L(t,s) + P(t) \quad\Rightarrow\quad L(t,s) = \int_{-\infty}^{t} P(t')\, e^{-s\,(t-t')}\, dt'

Every past watt is still in there, discounted by how long ago it was produced. As a function of ss, this is the Laplace transform of the power history, and the bank samples it at N values of ss. Getting the history back means inverting the transform. Post showed that, using real values of ss only, the inverse can be approximated with derivatives along ss (eq. 2.3 of the paper):

T(t,τ∗)=(−1)kk! sk+1 ∂kL(t,s)∂sk,s=kτ∗T(t, \tau^*) = \frac{(-1)^k}{k!}\, s^{k+1}\, \frac{\partial^k L(t,s)}{\partial s^k}, \qquad s = \frac{k}{\tau^*}

T(t,τ∗)T(t, \tau^*) estimates the power τ∗\tau^* seconds ago, and the estimate becomes exact as k→∞k \to \infty. Since s=1/τs = 1/\tau, the cell centered on the EWM with time constant τ looks back τ∗=kτ\tau^* = k\tau. With k = 0 there is no derivative, and T=s L=EWMτT = s\,L = EWM_\tau.

The derivative along ss is computed with finite differencesM4, across neighboring EWMs instead of across time steps. A k-th derivative needs k + 1 neighbors, and for the cell centered on EWM i the weight on neighbor j is

wij=(−1)k sik+1∏m≠j1sj−smw_{ij} = (-1)^k\, s_i^{k+1} \prod_{m \neq j} \frac{1}{s_j - s_m}

with the product over the other neighbors. On an evenly spaced ss axis these weights are binomial coefficients with alternating signs (eq. 2.5). The authors read them as bands of excitation and inhibition between neurons.

The response of one time cell to a single impulse is (eq. 3.2)

T(t,τ∗)=1τ∗ kk+1k!(tτ∗)ke−k t/τ∗T(t,\tau^*) = \frac{1}{\tau^*}\,\frac{k^{k+1}}{k!}\left(\frac{t}{\tau^*}\right)^{k} e^{-k\,t/\tau^*}

It is zero at the moment of the impulse and peaks exactly τ∗\tau^* later. Time appears only as the ratio t/τ∗t/\tau^*, so every cell has the same shape, stretched: the standard deviation over the mean is 1/k+11/\sqrt{k+1} for all of them (eq. 3.13). That is the scale invariance.

The spacing rule is eq. 2.6 of the paper, k2Δ<s\frac{k}{2}\Delta < s, with Δ\Delta the gap between neighboring rates. On a log-spaced bank with neighbors a factor 1+α1+\alpha apart, Δ≈αs\Delta \approx \alpha s, and the rule becomes kα<2k\alpha < 2. Covering τmin\tau_{min} to τmax\tau_{max} takes (eq. 2.9)

N=1+ln⁡(τmax/τmin)ln⁡(1+α)N = 1 + \frac{\ln(\tau_{max}/\tau_{min})}{\ln(1+\alpha)}

EWMs. From 12 s to 4 h, that gives the smallest bank for each order:

Order kFactor between neighbors must stay belowEWMs needed
0 (the EWM)anyany
2212
41.519
81.2533
121.1747

These are the bare minimum: right at the limit, a k = 8 time cell still peaks about 10% late and 20% too low. Workout Reserve's twelve EWMs are about 1.9 times apart on average, enough for k = 2 but not for the k = 4 of this page, which is why its time cells come out lower and wider than the ideal.

(The paper calls the integrator t(τ,s)t(\tau, s) and counts τ∗\tau^* as negative. I keep tt for time, as in the rest of the course, and count τ∗\tau^* back from now.)