T O P I C R E V I E W |
sreelakshmi |
Posted - 10/08/2017 : 10:19:15 PM Origin Ver. and Service Release (Select Help-->About Origin): Operating System:
Hi, I need to build a function in origin to fit my data. It contains a summation and a factorial. Here the function,
y = Sum[ (a1^m/m!* exp(-(x-a2+(m*Eph))^2)/(2*a3^2)]
This equation is to fit my data with a progression of Gaussians. Here summation is over m (m is actually the number of Gaussians used for fitting) whose value is starting from 1. The fitting parameters are [m,a1,a2,a3] and Eph is a constant. I am not good in programming. So please help me!! |
2 L A T E S T R E P L I E S (Newest First) |
sreelakshmi |
Posted - 10/10/2017 : 6:42:38 PM Hi, I used the fitting function builder. There I defined the dependent and independent variables. Defined the parameters m,a1,a2,a3. Then I defined the function as follows,
void _nlsffrankk( // Fit Parameter(s): double m, double a1, double a2, double a3, // Independent Variable(s): double x, // Dependent Variable(s): double& y) { // Beginning of editable part
double Factm = 1.0; const double Eph = 0.17; { double bb = 0; for(int ii =1; ii<=m; ii++) { Factm *= ii; bb = ( ( (6.606*10^-34) * (1240/x))^3) * 1.4 * (a1^m/ Factm) * exp (-( (x*a2+m*Eph)^2)/(2*a3^3)) + bb; } return bb; } // End of editable part
I tried the syntax for factorial you send me, but didn't work. So I used another cord as above. But the program is giving an error as 'Invalid return statement'. Here 'm' is also a parameter. |
Shirley_GZ |
Posted - 10/09/2017 : 04:56:31 AM Hi sreelakshmi,
We have a FAQ page to teach you how to define a summation function, see http://www.originlab.com/doc/Quick-Help/Summation-DoubleIntegral-Func
For the factorial m!, please try one of the functions
http://www.originlab.com/doc/LabTalk/ref/Fact-func or http://www.originlab.com/doc/LabTalk/ref/Gamma-func
Please let me know if any problem.
Thanks, Shirley OriginLab
Originlab Technical Service Team |
|
|