So the integral computation for W'bal was expensive.
I tried to optimise from a domain and programming perspective, where Dave Waterworth, a mathematician found a much more elegant and fast reformulation.
This means W'bal can EASILY be computed as you ride.
To explain the math here are his words;
I posted a comment on you Blog post on optimising the Wbal model. I've done some more thinking and I defn think it can be done without visiting the previous samples as the Skiba formula can be decomposed further, i.e. From your blog I believe the integral part of the equation is:
Basically this takes a weighted sum of preceding W'exp samples where the weight decays at a rate determined by tau, older samples are weighted less than newer ones. We can approximate as a sum provided tau is large compared to Ts (the sample rate):
Basic properties of exponential functions allow the formula to be rearranged as below. Written this way, the integral can be computed as a running sum rather than an inner / out loop.
i.e. Decompose into:
The sum can be updated at each time step, then the integral calculated very efficiently.
The same logic can be applied if the time step isn’t uniform as the as the original integral can be rearranged before converting to discrete form – you’d just need to use a numerical integration technique which can handle variable step length (I'd imagine the above will be fine, just vary Ts).
I tried to optimise from a domain and programming perspective, where Dave Waterworth, a mathematician found a much more elegant and fast reformulation.
This means W'bal can EASILY be computed as you ride.
To explain the math here are his words;
I posted a comment on you Blog post on optimising the Wbal model. I've done some more thinking and I defn think it can be done without visiting the previous samples as the Skiba formula can be decomposed further, i.e. From your blog I believe the integral part of the equation is:
Basically this takes a weighted sum of preceding W'exp samples where the weight decays at a rate determined by tau, older samples are weighted less than newer ones. We can approximate as a sum provided tau is large compared to Ts (the sample rate):
Basic properties of exponential functions allow the formula to be rearranged as below. Written this way, the integral can be computed as a running sum rather than an inner / out loop.
i.e. Decompose into:
The sum can be updated at each time step, then the integral calculated very efficiently.
The same logic can be applied if the time step isn’t uniform as the as the original integral can be rearranged before converting to discrete form – you’d just need to use a numerical integration technique which can handle variable step length (I'd imagine the above will be fine, just vary Ts).