How to code the same fitting using python

42 views
Skip to first unread message

Jasno

unread,
Apr 3, 2019, 12:17:28 PM4/3/19
to Zunzun.com discussion group
Hi

I have had a play with the site and come down to this equation

y = a + b*ln(f*x) + c*ln(f*x)2 + d*ln(f*x)3


generating the best fit for my data.

What I'd like to do now is code this in python somehow so as I generate "similar" data I can generate the
coefficients locally without having to take time on your server. 

Do you have any pointers to how the coefficients to this function can be found using python? I had a poke 
around with curve_fit from scipy.optimize, feeding it the same data I get coefficients of

a = -3.36852072e+02  
b = 2.66488521e+02 
c = -5.42969253e+01  
d = 3.62117782e+00
e = 2.20000551e-04

but you give me

a = -1.8946171615656505E+02
b =  2.0231670330576478E+02
c = -4.7444908201945879E+01
d =  3.6211737000212514E+00
f =  1.1708550299621606E-04

But i'm a bit lost as to why they are different or what I can do to get them the same?


Are you using something entirely different to solve this problem?

-- 
Jason

zunzun.com

unread,
Apr 3, 2019, 12:37:55 PM4/3/19
to Zunzun.com discussion group
You have two options: run the web site locally, or use the pyeq3 fitting library in your own Python files.

If you want to run the entire web site locally on your own Linux server, the source code and installation instructions are at https://bitbucket.org/zunzuncode/zunzunsite3

If you want to use the underlying pyeq3 fitting library in your own Python code, you can use "pip3 install pyeq3" and the examples are online at https://bitbucket.org/zunzuncode/pyeq3/src/ in the Examples directory, you should have scipy installed to use the examples. I suggest running the FitOneNamedEquation_2D.py or FitUserDefinedFunction_2D.py examples in the "Simple" directory, depending on whether you used a specific named equation or a User Defined Function. There are a kajillion different examples, these are good starting points.

Please let me know if you have any questions, my e-mail address is zun...@zunzun.com and I will be glad to advise.

James
Reply all
Reply to author
Forward
0 new messages