Calculations with an exponentially-weighted moving average

793 Views Asked by At

I need help figuring out the following formula:

enter image description here

Where:

CTLy = yesterdays CTL

TSS = current Training Stress Score

TC_c = your CTL Time Constant

Now I have TSS, thats a number between 20-500

About the CTL they say:

CTL is calculated as an exponentially-weighted moving average of daily TSS values, with the default time constant set to 42 days. CTL can therefore be viewed as analogous to the positive effect of training on performance in the impulse-response model, i.e., the first integral term in Eq. 1, with the caveat that CTL is a relative indicator of changes in performance ability due to changes in fitness, not an absolute predictor (since the gain factor, ka (or k1), has been eliminated).

Can anyone make an example with lets say a TSS = 100 ?

So let's say every day from today on I have TSS = 100

 CTL_day_1 = 100 * (1-CTL_exp) + (CTL_start * CTL_exp)
 CTL_day_2 = 100 * (1-CTL_exp) + (CTL_day_1 * CTL_exp)
 CTL_day_3 = 100 * (1-CTL_exp) + (CTL_day_2 * CTL_exp)

But I'm not sure what exactly will CTL_exp and CTL_start be in numbers and how will they change?

Update

So I figured out that I can get the desired result like so:

public function ctlFilter($tss, $constant, $start){
    return $tss * (1-(exp(-1/$constant))) + $start * exp(-1/$constant);
}

calling the function like:

$day1 = $this->ctlFilter(100, 42, 0);
$day2 = $this->ctlFilter(100, 42, $day1);

But the question remains: I would like to know what is going on "behind the scene". So if anyone can explain, like Alfred Einstein sayd to a 6 year old, that would be much appreciated. Thank you.

2

There are 2 best solutions below

3
On BEST ANSWER

As you correctly mentioned, Chronic Training Load (CTL) is an exponential moving average (EMA) of the daily Training Stress Score (TSS). Your TSS can vary a lot with time so you need to average it (for example, with EMA) in order to see the trend. The equation for CTL would look like this

$CTL_t = \alpha \cdot TSS_t - (1-\alpha) \cdot TSS_{t-1}$

Now let's generate some random TSS data (between 25 and 100) for 100 days and apply ExponentialMovingAverage[] to it. I have chosen low alpha for large smoothing of the data. High alpha will result in small smoothing.

TSS = RandomInteger[{25, 100}, 100];
alpha = 0.1;
CTL = ExponentialMovingAverage[TSS, alpha];
ListLinePlot[{TSS, CTL}, PlotLegends -> {"TSS", "CTL"}]

enter image description here

1
On

using your CTL equation: assuming CTL_start = 10

here is some Mathematica code visualising the accumulation over 42 days with stress = 100

I'm not familiar with CTL yet but It looks like it works like compound interest or the Golden ratio?

CTL[CTLday1_] := CTLday1 + (100 - CTLday1)/42

accumulatingCTL = N[NestList[CTL, CTLstart, 42]]

CTLstart = 10

ListPlot[accumulatingCTL]

enter image description here

hope this is some use to you

Note: I just learned on Kahn academy that functions which take their previous output as their input: CTLday2 = CTLday1 + (100 - CTLday1)/42 are called "recursive functions". A famous example is Newton's Method. They usually produce a sequence in which element n+1 is generated from element n. We start with a base case. Every term is defined in terms of the term before it.

Sometimes an "explicit function" can be found which will give you any element you like if you know its index.