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
 Sum in fit 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
espenhjo Posted - 09/18/2003 : 02:47:26 AM
Hi,
I have a function containing a sum of n functions with n going from 1 to infinite (or in practice from 1 to 100). How should I write this function in the NLSF?
Do I have to implement some sort of loop in the function with accumulating values, or should I use an integral instead?

Regards,
Espen
4   L A T E S T    R E P L I E S    (Newest First)
easwar Posted - 09/22/2003 : 1:27:25 PM
Hi Espen,

Thanks for posting more details and the equation etc. I gather that you have Origin 7 and so can use Origin C in NLSF.

With Origin C, you do not have to use a dataset to compute the sum, but can do this directly inside the funciton.

Let me take a simple equation to illustrate.
Say, your fitting function is:
E(q) = q^2 + Summation_over_n(n * q / a)
where a is a fitting parameter.

Define a new function in NLSF where you specify 'a' as the fitting parameter, and then name the indep var as 'q' and dep var as 'E'.
Click the 'Edit in Code Builder' button, and enter the following in the editable region:
// Beginning of editable part
double dSum = 0;
for(int n = 1; n < 101; n++)
{
dSum += n * q / a;
}
E = q^2 + dSum;

You can then try fitting with this function. May want to simulate some data with this function, add some random noise to the simulation, and fit that with the function to see how it works. Note here that the summation is from 1 to 100. You could define a Constant in NLSF to hold the limit to which the summation should be performed, rather than hard coding it in the function.

Hope this helps and you can change this to incorporate your function.

Easwar
OriginLab.

espenhjo Posted - 09/22/2003 : 05:45:28 AM
I guess it's hard for you to see the equation as long as it is situated on my harddisk!
Here it is:

espenhjo Posted - 09/22/2003 : 05:35:44 AM
Thanks Easwar,
I found some help in the article “Fitting with Integrals”. I am not completely satisfied though, so I’ll tell you what my problem is.
I have one dataset for the independent variable, q, and one set of experimental values constituting the dependent variable, E. There is one unknown parameter, a, that I want to extract from the NLSF. The other parameters, D and big delta, are known.

The equation looks like:


What I figured out is that I could exchange the summation with an integral and set n to a high number, e.g. 100 or 1000. By guessing the value for a, the integral part of the equation could be calculated for each q and build a dataset in a column. The next column would then give the integrals using the integral command on the previous column. We then store a as a temporary parameter (e.g. STORE). Then the full equation could be calculated in the next dataset. The experimental data is then set equal to this last dataset. The whole sequence is then run again if a has changed.
What do you think? Does this sound as a good solution? Could anyone help me with some code here that is Origin C compatible?

Regards,
Espen
easwar Posted - 09/20/2003 : 2:24:07 PM
Hi Espen,

Please take a look at this knowledge base item and see if this applies to you:
http://www.originlab.com/www/support/resultstech.asp?ItemID=121&VersionID=All&CatID=Fitting&TypeID=Tip&Language=Details&TitleID=Fitting+with+Integrals+<!--+math+data+NLSF+-->

If not, please post more details, such as the expression, or contact your local tech support office for more help.

Easwar
OriginLab.


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