Home > Net >  fitting a non-smooth curve that is described by three equations
fitting a non-smooth curve that is described by three equations

Time:03-22

I'm facing the following problem:

I would like to fit a curve which is described by an underlying model containing a set of three different functions for three different x-ranges in order to determine three unknown parameters (xG1, xG2 and b) of four overall within these functions.

For x smaller the transition value xG1 the function-value shall be zero:

f(x) = 0 for x < xG1 

For x between xG1 and xG2 the curve follows a power-law:

f(x) = ( (xG2 - 2 a ⁄ b) / (a - 2 a ⁄ b) )∙[(x - xG1) / (xG2 - xG1)]^2 for xG1 ≤ x ≤ xG2

For x bigger xG2 the curve follows a linear relation again:

f(x) = (x - 2 a ⁄ b) / (a - 2 a⁄b) for x ≥ xG2 

So my issue at the moment is that the transition values xG1 and xG2 themselves are unknown parameters to be determined, so I can't use a piecewise fitting in order to determine them.

I'm bound to solving this issue using matlab.

I've tried using the curve-fitting-toolbox but it's not really suited for a problem like that, which is why I'm currently trying to find a way using the global optimization-toolbox.

Maybe someone has an idea for solving this issue with the global optimization toolbox or in general with a completely different approach using matlab.

Thanks in advance

Best regards

CodePudding user response:

I had to solve a similar problem once where I had a piecewise defined model and the crossover point between the two expressions was a free parameter.

What I did was start with an initial guess of all of the model parameters and then minimized the squared error. This was done by gradient decent in my case where I numerically evaluated the gradient against all of the model parameters including the crossover point. I didn't use MATLAB at the time, but the same approach could be applied here.

Another approach is to let MATLAB do all of the heavy lifting. If you have access to the optimization toolbox you can use functions such as fmincon to solve your fit. fmincon takes as an input a vector of the model parameters and a cost function which it attempts to minimize. The vector of model parameters in this case would also contain the crossover points and your cost function would be the error in the model where the cost function would account for the varying crossovers.

  • Related