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
 All Forums
 Origin Forum
 Origin Forum
 Fitting summation function

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
hobkim Posted - 06/19/2021 : 02:12:00 AM
Hi,

I would like to ask how to build the fitting function below that includes summation.



I was trying to fit this in NLfit using the Function Type of Equations. So, I put x in the independent variables, and y in the dependent variables and, A, B, and C in the Parameters. But I have no idea of how to deal with the latter term having the summation function.

Perhaps, it should be done using Origin C or a different function type? Actually, I checked some past postings in this forum to get some hints but unfortunately I was not able to understand how it goes.

Can you please help me with building this equation?
10   L A T E S T    R E P L I E S    (Newest First)
hobkim Posted - 06/25/2021 : 01:27:23 AM
It works! Thank you very much for your time and effort to help me!
Have a great day and All the best!
YimingChen Posted - 06/24/2021 : 1:56:38 PM
Please define Python function with script below:

from mpmath import nsum, exp, inf
import numpy as np

def f(x, nn, B, C):
    return 4*np.pi/nn**3*(x-B+C/nn**2)
    
def g(x, B, C):
    return (x-B)*np.pi*exp(np.pi)*(C/(x-B))**0.5/np.sinh(np.pi*(C/(x-B))**0.5)

def Elliot(x, A, B, C):
    return [float(A*(g(t, B, C) + C*(nsum(lambda nn: f(t,nn, B, C),[1, inf])))) for t in x]




Make sure to install mpmath Python package (menu Connectivity->Python Pakcages...)

James
hobkim Posted - 06/24/2021 : 11:33:33 AM
Thanks to your help, I finally tried to build the equation but it was not working very well.
I think it's because there is a difference between my equation and the equation of the example (https://www.originlab.com/doc/python/tools/NLFit-and-Peak-Analyzer).

In the example equation which is x, y function, there is no x in the function but instead t. In my equation which is also x, y function, there is already x.

I guess there would be something that I have to modify perhaps the iteration part "for in". I have tried this and that, but unfortunately, it never works. Could you please have a look at the function that I built below and tell me what's wrong?

from mpmath import nsum, exp, inf
import numpy as np

def Elliot(x, A, B, C):
sm = [float((nsum(lambda ii: 1/ii**3*(x-B+C/ii**2),[0, inf]))) for x in t]
return [A*((x-B)*np.pi*exp(np.pi)*(C/(x-B))**0.5/np.sinh(np.pi*(C/x-B)**0.5)+C*4*np.pi*t)) for t in sm]

I really appreciate your help.
hobkim Posted - 06/24/2021 : 10:02:12 AM
Thank you very much, James,
It finally works!
Now I think I can try my equation as well!
Thanks again!
YimingChen Posted - 06/24/2021 : 09:07:10 AM
Please change the function body to:
y = MassDiffuse(x, y0, D, L)


James
hobkim Posted - 06/23/2021 : 10:40:47 PM
quote:
Originally posted by YimingChen

You will need to upgrade your Origin to 2021b to see the option to use Python. Thank you.

James



Thanks for your comment.
I upgraded Origin to 2021b and I tried the example that you first suggested.
But it does not work showing the error popup window. It does not allow the next step.



Could you please check this and comment?
Thank you for your support.
YimingChen Posted - 06/23/2021 : 3:10:48 PM
You will need to upgrade your Origin to 2021b to see the option to use Python. Thank you.

James
hobkim Posted - 06/23/2021 : 3:07:50 PM
quote:
Originally posted by YimingChen

You will need to define such function with Python in Origin. See the tutorial below:
https://www.originlab.com/doc/python/tools/NLFit-and-Peak-Analyzer

James



Hi, I tried it according to your guide and I realized that this can be done using the python function. However, I was not able to find the python in the function type as you can see in this image.



Actually, I confirmed the python embedded while I was reinstalling the whole software. But still, it's not activated. Could you please give some guideline to run the python for the Fitting Function Builder?
hobkim Posted - 06/22/2021 : 1:09:55 PM
quote:
Originally posted by YimingChen

You will need to define such function with Python in Origin. See the tutorial below:
https://www.originlab.com/doc/python/tools/NLFit-and-Peak-Analyzer

James



Thank you so much.
Please let me try this!
YimingChen Posted - 06/21/2021 : 08:49:14 AM
You will need to define such function with Python in Origin. See the tutorial below:
https://www.originlab.com/doc/python/tools/NLFit-and-Peak-Analyzer

James

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000