Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

flat6

macrumors regular
Original poster
Oct 24, 2004
244
0
I guess this is a question for the science/math/engineering people on here: I'm trying to curve fit some data to a non-trivial equation. What do I use? I've got Mathematica but am rather inept with it, is there any simple (and free/trial) curve-fitting program out there I can use?

BTW, the equation is y=A(x-B)^C, and I'm trying to get numerical values for A and C.

Thanks!
 
Do you know what B is, or do you not care what B is?

If B is known then taking logs might help

log y = C(log A + log (x-B))

If B is unknown this probably wont work. The problem is y=A(x-B)^C is a non-linear model and most software deals with linear models.

You can probably try it by hand.

You want to find the least-squares estimators. That is the values of A,B,C (call them A*,B*,C*) that minimizes the sum over all data of (y - A(x-B)^C)^2
 
I guess this is a question for the science/math/engineering people on here: I'm trying to curve fit some data to a non-trivial equation. What do I use? I've got Mathematica but am rather inept with it, is there any simple (and free/trial) curve-fitting program out there I can use?

BTW, the equation is y=A(x-B)^C, and I'm trying to get numerical values for A and C.

Thanks!

Perhaps Prism can do this?

David
 
Do you know what B is, or do you not care what B is?

If B is known then taking logs might help

log y = C(log A + log (x-B))

If B is unknown this probably wont work. The problem is y=A(x-B)^C is a non-linear model and most software deals with linear models.

You can probably try it by hand.

You want to find the least-squares estimators. That is the values of A,B,C (call them A*,B*,C*) that minimizes the sum over all data of (y - A(x-B)^C)^2

Yes, I should have mentioned that originally, sorry. B is known.

So I can linearize the equation and try to run a normal "Fit"-type command on it.
 
Yes, I should have mentioned that originally, sorry. B is known.

So I can linearize the equation and try to run a normal "Fit"-type command on it.

Yes, if B is known, then you are fitting y' = a'+b'x'

where y' = ln y
a' = C*ln A
b' = C
x' = x-B

This is a standard linear fit.

SO you can get estimates for a' and b' and use those to solve for A and C.
 
i use excel for this as excel handles data sets very well and can fit regressions up to i think 9 degrees.

you dont need solver, just graph the line and then fit a trendline to the graph would work as well

im assuming you have some version of office as otherwise it wouldnt be free.
 
The main problem with Prism is that is not exactly cheap (~$400-ish), although it works very well for me (site license at work).

How about ProFit? http://www.quansoft.com/feat.html
I personally have not tried the app, but it sounds it might be no slouch either.
 
Yes, if B is known, then you are fitting y' = a'+b'x'

where y' = ln y
a' = C*ln A
b' = C
x' = x-B

This is a standard linear fit.

SO you can get estimates for a' and b' and use those to solve for A and C.

Right; only problem is that there's 2566 data points. I'll try some of the programs mentioned in this thread...
 
Right; only problem is that there's 2566 data points. I'll try some of the programs mentioned in this thread...

True, but my point was that if you are trying to fit a standard linear fit the number of applications that can do this is more than would fit the original equation that you had.
 
True, but my point was that if you are trying to fit a standard linear fit the number of applications that can do this is more than would fit the original equation that you had.

Absolutely right, that was a handy tip.

Thanks for the advice guys.
 
I guess this is a question for the science/math/engineering people on here: I'm trying to curve fit some data to a non-trivial equation. What do I use? I've got Mathematica but am rather inept with it, is there any simple (and free/trial) curve-fitting program out there I can use?

BTW, the equation is y=A(x-B)^C, and I'm trying to get numerical values for A and C.

Thanks!
Excel is a very blunt instrument. There are several excellent charting/curve-fitting apps for the Mac. However, I keep coming back to KaleidaGraph. If you can calculate the partial derivatives with respect to each fitted parameter, then KaleidaGraph will quickly curve fit virtually any non-linear function. It will also fit your data to your function if you don't take the partials, but this is not as reliable. Your function is trivial to fit.

A 45-day free trial is available. Try it.
 
Excel is a very blunt instrument. There are several excellent charting/curve-fitting apps for the Mac. However, I keep coming back to KaleidaGraph. If you can calculate the partial derivatives with respect to each fitted parameter, then KaleidaGraph will quickly curve fit virtually any non-linear function. It will also fit your data to your function if you don't take the partials, but this is not as reliable. Your function is trivial to fit.

A 45-day free trial is available. Try it.

I'm giving KaleidaGraph a try at the moment, I've pasted in my data into its data-window, one column (x-axis) it's calling "A", and the second (y-axis) it's calling "B". I've got it to plot (complete with purdy "Demo Copy" splattered across :) ) but how do I do a curve fit? I've defined "m1*(B-1.717)^m2;m1=800;m2=1.5;" in the General curve fit library, but when I try to plot it gives "Singular coefficient matrix" error.
 
I'm giving KaleidaGraph a try at the moment, I've pasted in my data into its data-window, one column (x-axis) it's calling "A", and the second (y-axis) it's calling "B". I've got it to plot (complete with purdy "Demo Copy" splattered across :) ) but how do I do a curve fit? I've defined "m1*(B-1.717)^m2;m1=800;m2=1.5;" in the General curve fit library, but when I try to plot it gives "Singular coefficient matrix" error.
Your independent variable is m0. Your undetermined parameters to be fitted are m1, m2, and m3. There is no need to treat the offset as a constant (1.717). KaleidaGraph will fit it with aplumb.

Your function should be:

m1*(m0-m3)^m2; m1=800;m2=1.5;m3=1.7


Check Specify Partials


Click dF/dM1 =

Type (m0-m3)^m2


Click dF/dM2 =

Type m1*ln(m0-m3)*(m0-m3)^m2


Click dF/dM3 =

Type -m1*m2*(m0-m3)^(m2-1)
 
Your independent variable is m0. Your undetermined parameters to be fitted are m1, m2, and m3. There is no need to treat the offset as a constant (1.717). KaleidaGraph will fit it with aplumb.

Your function should be:

m1*(m0-m3)^m2; m1=800;m2=1.5;m3=1.7

Excellent, that worked well.

Check Specify Partials


Click dF/dM1 =

Type (m0-m3)^m2


Click dF/dM2 =

Type m1*ln(m0-m3)*(m0-m3)^m2


Click dF/dM3 =

Type -m1*m2*(m0-m3)^(m2-1)

What are the partials for?
 
...

What are the partials for?
This is a part of the standard algorithm for linearizing non-linear functions in parameter space near the optimal value of each parameter. You can find in-depth derivation and analysis in books on nonlinear regression. If you can't get one, I can send you a file that explains showing the derivation.
 
This is a part of the standard algorithm for linearizing non-linear functions in parameter space near the optimal value of each parameter. You can find in-depth derivation and analysis in books on nonlinear regression. If you can't get one, I can send you a file that explains showing the derivation.

Ah, I see. I'll do without the in-depth derivation for now, your first sentence summed things up nicely and satified my curiosity.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.