The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Gaussian progression fitting with a summation
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

sreelakshmi

India
2 Posts

Posted - 10/08/2017 :  10:19:15 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Posted - 10/09/2017 :  04:56:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

sreelakshmi

India
2 Posts

Posted - 10/10/2017 :  6:42:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000