Jump to content

Numerical Power Regression Method


Farzad Bashtani

Recommended Posts

I have a set of X and Y points and I want to fit a Power curve to them.

 

Y = a*X^b + c

 

whats the algorithm for determining a,b,c?

 

[math] log(Y-c)=b(log \ x \\ + log \ a)[/math]

 

So now use your favorite method for fitting a line. A least-squares fit is one method.

 

You may get a good idea of the value for c, from the behavior of Y for small values of X.

 

However, the first step ought to be looking at the plot of log Y to see if a power law is even reasonable.

Link to comment
Share on other sites

[math] log(Y-c)=b(log \ x \\ + log \ a)[/math]

 

So now use your favorite method for fitting a line. A least-squares fit is one method.

 

You may get a good idea of the value for c, from the behavior of Y for small values of X.

 

However, the first step ought to be looking at the plot of log Y to see if a power law is even reasonable.

 

 

thanks for the advise

there are two things I need to mention

 

My function is Y=a*(x^b)+c . so it becomes Log (y-c) = Log a + b*Log x .

 

about the value of c I still have no Idea how I can determine it !

 

I give you a sample of the data that I'm trying to fit with this curve.

 

I would be appreciated for your advice

K(t)_K(0)_OUTPUT.txt

Link to comment
Share on other sites

My function is Y=a*(x^b)+c . so it becomes Log (y-c) = Log a + b*Log x .

 

about the value of c I still have no Idea how I can determine it !

 

Without the c constant in your equation that log operation would have been slightly more justified since it would turn your nonlinear regression problem into a linear one in variables log x and log y. However, it's possible you are stuck with having to do the full nonlinear thing. With scilab or matlab that shouldn't be so hard if you are familiar with numerical methods. Define a cost function, for example

 

[math]cost(a, b, c) = \Sigma_i (y_i - a x_i^b - c)^2[/math],

 

where [math](x_i, y_i)[/math] are your measured data points and minimize that wrt a, b and c using for example fminsearch in Matlab (or manually using some appropriate iterative algorithm). You could also choose a different cost function instead of the least squares approach, for example minimizing the sum of the absolute values of the error. There are advantages (and disadvantages) with such an approach, google robust curve fitting.

 

Good luck.

Edited by baxtrom
Link to comment
Share on other sites

Without the c constant in your equation that log operation would have been slightly more justified since it would turn your nonlinear regression problem into a linear one in variables log x and log y. However, it's possible you are stuck with having to do the full nonlinear thing. With scilab or matlab that shouldn't be so hard if you are familiar with numerical methods. Define a cost function, for example

 

[math]cost(a, b, c) = \Sigma_i (y_i - a x_i^b - c)^2[/math],

 

where [math](x_i, y_i)[/math] are your measured data points and minimize that wrt a, b and c using for example fminsearch in Matlab (or manually using some appropriate iterative algorithm). You could also choose a different cost function instead of the least squares approach, for example minimizing the sum of the absolute values of the error. There are advantages (and disadvantages) with such an approach, google robust curve fitting.

 

Good luck.

 

 

thanks a lot for your advise.

 

now I know what I need to do.

 

now the problem is the fminsearch function. Im using c++ for this project. so I need to write this function by myself.

 

can you help me with the algorithm of this? how am I suppose to find this minimum value for the cost function?

 

---Im going to add a new topic on the forum for this issue

Edited by Farzad Bashtani
Link to comment
Share on other sites

can you help me with the algorithm of this? how am I suppose to find this minimum value for the cost function?

 

You could check out the gradient descent method, which is perhaps the simplest minimization algorithm. Basically it means taking downhill steps in the direction of "greatest slope" until the bottom (miminum) is reached. So, you need the gradient of the cost function, i.e. the derivatives wrt a, b and c. Those you could approximate using for example central difference approximations.

 

The best way to learn about minimization is probably to pick up an introductory textbook on numerical analysis. There you will find examples on how to implement this and other more advanced (and more effective) methods.

Link to comment
Share on other sites

  • 1 month later...

I have a set of X and Y points and I want to fit a Power curve to them.

 

Y = a*X^b + c

 

whats the algorithm for determining a,b,c?

 

 

 

(tt+.^b) .00004 = (tt-.C)(*x^A) (-.00003 Y.)

 

 

By Olala

Edited by Lala
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.