Author |
Topic |
|
DrHoas
Posts |
Posted - 07/22/2008 : 10:40:13 AM
|
Hello,
I want to define my own fitting function but I don't know how to determine the initialization code. Without entering data in the Parameter Initialization box my function (and also the built-in-functions) doesn't work.
How can I determine the parameter initial values?
Thanks for your help.
Philipp
P.S. OriginPro 8G SR2 |
|
easwar
USA
1964 Posts |
Posted - 07/22/2008 : 11:25:01 AM
|
Hi Philipp,
First of all, the built-in functions all have their own code for initial parameter estimation, so you should not have to enter initial values for those functions (unless the code comes up with values that are not at all suitable for the present data and function, in which case one may have to enter "known/close" values to push the fit to a certain parameter space...)
As for user-defined functions, one option, at least to begin with, is to just put fixed values for parameters that are suitable for most of your data...and the iterative procedure usually will converge to final solution if such fixed initial values are not that far off...
To specify fixed initial values, please see the following section of the help file: http://originlab.com/www/helponline/Origin8/en/regression_and_curve_fitting/parameter_initialization.htm
Also, you can use the Simulate tool (menu: Analysis->Fitting->Simulate Curve) to determine what would be a good set of fixed values to use for your function and your typical data)
If fixed values do not work well, then one needs to write Origin C code to examine the data to come up with initial estimates, which is what we do with built-in functions. If you are interested in writing code, you could e-mail tech support and ask for help, sending details of your fitting function and some sample data.
Easwar OriginLab
|
|
|
DrHoas
Posts |
Posted - 07/23/2008 : 04:41:48 AM
|
Hello Easwar,
thanks for your fast reply.
I forgot to declare initial values for my parameters. I thought Origin chooses them itself if not specified by the user.
So now I managed to build my own fitting function, but:
Actually I don't want to fit a curve but a surface or multidimensional data. So I defined one dependent variable (alpha) two independent variables (q, xE), built a new function (alpha = a+b*q^c*xE^d) and tested it. Now the preview window shows me two x-y-graphs. That's not what I wanted. Shouldn't the preview window show me a surface?
Thanks again,
Philipp |
|
|
larry_lan
China
Posts |
Posted - 07/23/2008 : 05:14:06 AM
|
Hi:
If there are only two independent variables in your fitting function, you can define it under Surface Fitting category. Then you can get a better preview. |
|
|
DrHoas
Posts |
Posted - 07/23/2008 : 09:44:04 AM
|
Hi,
ok, thanks.
I tried something else:
I produced x-values from -5 to 5 (step=1) an y-values with y=2.5*x^2. Then I defined a function y=ax^b+c an fitted the values. Origin tells me that a=2.5, b=2 and c=-1,32812E-7 (=0).That's what I expected.
The standard errors are 10.17483 (for a), 2.462 (for b) and 22.06383 (for c). What does that mean?
Thanks,
Philipp |
|
|
adamleewiner
China
Posts |
Posted - 07/23/2008 : 10:51:33 AM
|
You can find the answer about the standard error easily by looking in a math reference book or google-ing it. ...bla
quote: Originally posted by DrHoas
Hi,
ok, thanks.
I tried something else:
I produced x-values from -5 to 5 (step=1) an y-values with y=2.5*x^2. Then I defined a function y=ax^b+c an fitted the values. Origin tells me that a=2.5, b=2 and c=-1,32812E-7 (=0).That's what I expected.
The standard errors are 10.17483 (for a), 2.462 (for b) and 22.06383 (for c). What does that mean?
Thanks,
Philipp
|
|
|
DrHoas
Posts |
Posted - 07/23/2008 : 10:56:04 AM
|
now I tried the same but with x-values from -30000 to 30000 (step=1). The result is
a=2.51802 (should be 2.5), error=0.75434 b=1.9993 (should be 2), error=0.02768 and c=-157649,4628 (should be 0), error=9.22972E6
What happened now? Why do I not get the correct values and why is the error smaller for a, b and much bigger for c?
Philipp
|
|
|
ALacroix
France
1 Posts |
Posted - 07/25/2008 : 12:08:00 PM
|
Hi Easwar OriginLab ....& al. Is there an extra library of peak fitting functions parameterized with areas instead of amplitudes to properly implement constraints with share for spectra ( nmr) . Only gauss and Lorentz seem & not Pearson VII or voigt or mixt LzGauss.
May the minimizer be chosen between simplex Marquart Levenberg or others ?
Changing the engine and the wheels might be too much of a request.
Onmr & cellulose |
|
|
easwar
USA
1964 Posts |
Posted - 07/25/2008 : 5:12:22 PM
|
quote: Originally posted by DrHoas
now I tried the same but with x-values from -30000 to 30000 (step=1). The result is
a=2.51802 (should be 2.5), error=0.75434 b=1.9993 (should be 2), error=0.02768 and c=-157649,4628 (should be 0), error=9.22972E6
What happened now? Why do I not get the correct values and why is the error smaller for a, b and much bigger for c?
Philipp
Hi Philip,
I suggest you send your data/opj and your function/fdf to tech support so they can take a look.
Also please note that one can set bounds on parameters, so if you know your parameter is expected to stay within a known range you can set lower and upper bounds to help the fit converge better...typically the data and the function are not a "good match" and/or the function has too many parameters (overparameterized), some parameter values can end up to be "large/small" but still producing a fit line that goes thru the data...we cannot say why without seeing data and function.
Thanks,
Easwar OriginLab
|
|
|
easwar
USA
1964 Posts |
Posted - 07/25/2008 : 5:18:58 PM
|
quote: Originally posted by ALacroix
Hi Easwar OriginLab ....& al. Is there an extra library of peak fitting functions parameterized with areas instead of amplitudes to properly implement constraints with share for spectra ( nmr) . Only gauss and Lorentz seem & not Pearson VII or voigt or mixt LzGauss.
May the minimizer be chosen between simplex Marquart Levenberg or others ?
Changing the engine and the wheels might be too much of a request.
Onmr & cellulose
Hi,
Yes, some functions use A for amplitude instead of Area etc. If the function is defined one way and you want it another way, currently you need to define your version of the function by adding a user-defined function.
Can you summarize what functions are typical/needed for your field, and send tech support a message, with the proper function definitions or links to appropriate site pages if they exist? Then we can consider adding some of them if they are of common interest to many users.
As for Simplex, are you running ver 8 SR2? In SR2 in the NLFit dialog, I see an "S" button in the middle panel that does Simplex Approximation. Can you try that?
Thanks,
Easwar OriginLab
|
|
|
|
Topic |
|
|
|