differentiating the Veloclinic model for nonlinear least-squares fitting

Two posts ago I described fitting the linear CP model with an iteratively weighted least-square fit to approximate an envelope fit. The weights were either 1/t2 for points falling under the CP curve or 10k/t2 for points falling above the CP curve. This did a decent job in the example I showed of matching the fit using a 2-point method used in Golden Cheetah.

But of greater interest is using this method for my modified Veloclinic model. That model should do much better at fitting the full time spectrum of the power-duration data. The challenge there, however, is the model is nonlinear.

Nonlinear least squares fitting is described by Wolfram. In my last posts, I added weighting to the method described on the Wolfram page. Nonlinear least square fitting is a matter of navigating a hyperdimensional space, looking for the point where all error terms go to zero (where the model perfectly fits the data). There is no such point, so you search for it until improvement slows below some threshold, then declare victory. But the search involves finding the direction to zero, and that requires tracking the slope, and that requires derivatives. No problem -- it's easy to differentiate the Veloclinic model.

The model as I modified it consists of two components. First, the anaerobic component:

P11 / t) [1 − exp(−t / τ1) ] ,

and then an aerobic component, which I modified as follows:

P22 / t)1/2 [1 − exp(−[t/τ2]1/2) ] .

I'll call the total modeled power f, a function of time.

There's four parameters: P1, τ1, P2, and τ2. The model is clearly linear on P1 and P2. It's the τ1 and τ2 which are nonlinear.

First, the derivatives of f on P1 and P2 are trivial since the dependence is linear:

∂ f / ∂ P1 = [τ1 / t] [1 − exp(−t / τ1)]

∂ f / ∂ P2 = [τ2 / t]1/2 [1 − exp(−[t / τ2]1/2)]

The derivatives of the τ terms is a bit more complicated:

∂ f / ∂ τ1 = P1 [ (τ1 / t) (1 - exp[-t / τ1]) - exp(-t / τ1) ] / τ1

∂ f / ∂ τ2 = 1/2 P2 [ (τ2 / t)1/2 (1 - exp[-(t / τ2)1/2]) - exp(-[t / τ2]1/2) ] / τ2

I checked these numerically and made some corrections versus the originally posted derivatives.

Comments

Popular posts from this blog

Marin Avenue (Berkeley)

hummingbird feeder physics

Gallium Pro geometry