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 for Programming
 Forum for Origin C
 Help: Build up the summation fitting function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Vinh

Norway
1 Posts

Posted - 07/28/2016 :  06:51:28 AM  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:
I can't build up this function as a fit function. Any basic help in the right direction would be appreciated. The equation is below
F(t)=B_0+∑_(i=1-n)(B_i∙e^((-t)/τ_i ))

Edited by - Vinh on 07/28/2016 06:53:00 AM

yuki_wu

896 Posts

Posted - 08/07/2016 :  11:05:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can define the fitting function with an embedded For loop in the function definition box.

For example,
1.Define your fitting functions in the Function edit box:

y=func3(x, B_0, n)


2.Define the functions in the LabTalk Functions Definition and Initializations box

function B_i(double t) 
{
//define your function here
}

function τ_i(double t)
{
//define your function here
}

function func3(double t , double B_0, int n)      //Summation
{
   double aa=B_0;
   for(ii=1; ii<=n; ii++)
   {
       aa = B_i*exp((-t)/ τ_i) + aa;
   }
   Return aa
}


Hope it helps.

Yuki
OriginLab

Edited by - yuki_wu on 02/14/2017 10:23:30 PM
Go to Top of Page

kraamesh57

India
6 Posts

Posted - 07/21/2020 :  07:56:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Yuki Wu,
I am looking to fit an expression which involves summation. The expression is attached to this message. I am not able to find a solution even after reading many threads.
In the above post, the fitting parameter B_i and tau_i lie inside the summation but you have treated B_i and tau_i as a function. I could not understand this part why B_i is treated as a function. Since my expression contains 4 exponentials per term I am finding it difficult to write the expression. Any help to solve my problem will be greatly appreciated.
My problem
1. I need to do a fitting with summation
2. Fitting parameters ('i' number of parameters) are kept inside the summation
Please guide me on how to write the lab talk function or Origin C code.
Thanks in advance
Regards
Ramesh

Edited by - kraamesh57 on 07/21/2020 07:58:23 AM
Go to Top of Page

YimingChen

1618 Posts

Posted - 07/21/2020 :  3:06:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ramesh,

We did manage to build your fitting function using Python in Origin. Basically ni's in the fitting function can be passed as a vector into the fitting algorithm and generate the fitting result. Would you mind sending your data to <tech@originlab.com> and we can test further? Also I coded the script in our recently released Origin2021 beta2 version. Would you like to test in beta2 as well? Please let us know.

James

Edited by - YimingChen on 07/21/2020 3:08:03 PM
Go to Top of Page

kraamesh57

India
6 Posts

Posted - 07/22/2020 :  12:28:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear YimingChen
Thanks for the message and making a python code for the attached expression. I have sent an origin file to the following mail id tech@originlab.com (Email heading: Attn YimingChen from Ramesh Kumar) which has two different data set that can be modelled using the attached expression. There is a slight modification from my earlier expression. The new expression contains another integer parameter (gi). I have given you a possible starting parameters. I am not using the latest version of the origin hence it would be better if your code can be implemented older version also (Origin8.6)
Thanks
Ramesh
Go to Top of Page

kraamesh57

India
6 Posts

Posted - 07/22/2020 :  12:41:02 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Please use gi's as constants and I have given those values in the origin file.
and please assume Del = E/k_B to be consistent with the previous expression.
Regards
Ramesh
Go to Top of Page

YimingChen

1618 Posts

Posted - 07/22/2020 :  4:40:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
With Python's optimization package, we managed to fit your data. See attached.



James
Go to Top of Page

kraamesh57

India
6 Posts

Posted - 08/07/2020 :  2:04:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear YimingChen
Thank you for your valuable suggestions and effort. I could use the *.py module you have sent and fit the data successfully. I am hoping that this module would be useful to others who are interested to carry out fit with an expression which includes a summation.
Regards
Ramesh
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