# Non-linear curve fitting? browsing

• posted
0

Hey there, so I see that Pythonista has no access to SciPy which was the only way I knew how to do a non-linear curve fit in python. Do any of you know any way around this limitation? I'd really like to use my iPad for data analysis but this is holding me back.

• posted
0

polyfit in the numpy module does fitting to a polynomial. There are other more specialized methods also in the numpy module.

• posted
0

I'm aware of the polynomial fit, but I was hoping for something where I can specify some fit function like say a*e^(-x^2/b) where a and b are fit parameters. I can only find methods to do this with scipy. Do you know a method to do this on Pythonista?

• posted
0

https://en.m.wikipedia.org/wiki/Levenberg–Marquardt_algorithm

You have to manually compute the derivative wrt your free parameters at each x data point to form the jacobian matrix. For a simple example such as your function, you can analytically derive the jacobian (use sympy or pencil and paper).

• posted
0

lol i was about to write the same post...! Except i would rather compute the jacobian directly with a small increment.

• posted
0

that is another option, and is certainly the better general solution for dealing with user defined functions.... , but since most of the cost is going to be computation of the jacobian, an analytic solution will be much faster. I tend to deal with very large problems, but for typical curve fitting it is probably adequate.

Internal error.

Oops! Looks like something went wrong!