# curve-fitting software

Discussion in 'Mac Apps and Mac App Store' started by flat6, Mar 1, 2007.

1. ### flat6 macrumors regular

Joined:
Oct 24, 2004
#1
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!

2. ### swiftaw macrumors 603

Joined:
Jan 31, 2005
Location:
Omaha, NE, USA
#2
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

3. ### davidjearly macrumors 68020

Joined:
Sep 21, 2006
Location:
Glasgow, Scotland
#3
Perhaps Prism can do this?

David

4. ### mkrishnan Moderator emeritus

Joined:
Jan 9, 2004
Location:
Grand Rapids, MI, USA
#4
Actually, Excel can even do it, if all you need are the best fit constants. Look up the "Solver" feature in the help.

5. ### davidjearly macrumors 68020

Joined:
Sep 21, 2006
Location:
Glasgow, Scotland
#5
Yeah but Excel is pants compared to Prism.

6. ### flat6 thread starter macrumors regular

Joined:
Oct 24, 2004
#6
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.

7. ### swiftaw macrumors 603

Joined:
Jan 31, 2005
Location:
Omaha, NE, USA
#7
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.

8. ### dukebound85 macrumors P6

Joined:
Jul 17, 2005
Location:
5045 feet above sea level
#8
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.

9. ### nsbio macrumors 6502a

Joined:
Aug 8, 2006
Location:
NC
#9
The main problem with Prism is that is not exactly cheap (~\$400-ish), although it works very well for me (site license at work).

I personally have not tried the app, but it sounds it might be no slouch either.

10. ### flat6 thread starter macrumors regular

Joined:
Oct 24, 2004
#10
Right; only problem is that there's 2566 data points. I'll try some of the programs mentioned in this thread...

11. ### swiftaw macrumors 603

Joined:
Jan 31, 2005
Location:
Omaha, NE, USA
#11
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.

12. ### flat6 thread starter macrumors regular

Joined:
Oct 24, 2004
#12
Absolutely right, that was a handy tip.

13. ### MisterMe macrumors G4

Joined:
Jul 17, 2002
Location:
USA
#13
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.

14. ### flat6 thread starter macrumors regular

Joined:
Oct 24, 2004
#14
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.

15. ### MisterMe macrumors G4

Joined:
Jul 17, 2002
Location:
USA
#15
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.

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)

16. ### flat6 thread starter macrumors regular

Joined:
Oct 24, 2004
#16
Excellent, that worked well.

What are the partials for?

17. ### MisterMe macrumors G4

Joined:
Jul 17, 2002
Location:
USA
#17
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.

18. ### djdawson macrumors member

Joined:
Apr 28, 2005
Location:
Minnesota
#18
This package says it can do curve fitting, and it's free:

http://plot.micw.eu/

I've not used it, but at least it's free.

HTH

19. ### flat6 thread starter macrumors regular

Joined:
Oct 24, 2004
#19
Ah, I see. I'll do without the in-depth derivation for now, your first sentence summed things up nicely and satified my curiosity.

20. ### shwc macrumors regular

Joined:
Jul 2, 2005
#20
as to the original question...

The program Pro Fit should do the trick nicely.
http://www.quansoft.com/index.html

(I have used the program myself and find it quite useful)