Author |
Topic |
|
sreelakshmi
India
2 Posts |
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!! |
Edited by - sreelakshmi on 10/08/2017 10:21:38 PM |
|
Shirley_GZ
China
Posts |
|
sreelakshmi
India
2 Posts |
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. |
Edited by - sreelakshmi on 10/10/2017 6:44:29 PM |
|
|
|
Topic |
|
|
|