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
 help need in nonlinear fitting

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
fusswolf Posted - 04/18/2006 : 10:55:52 AM
Origin Version (Select Help-->About Origin): 7.0
Operating System:windows 2000
actually this is an integration problem which has been discussed before. but i still need some further help.
our data is the convolution results of two functions. one is a gaussian function as y1=A*exp(-(x/P1)^2) and the other one is a square pusle function as y2={(0,x<-P2/2)(1,-P2/2<x<P2/2),(0,x>P2/2)).here A,P1,P2 are parameters to fit. So,our fitting function looks like y3=y0+integration(y1[x]*y2[t-x])dx. (y0 is only for baseline,t is real variable). But i don't know how to write a piecewised function like y2.
Also the result of the integration can be calculated and it is an error function like: Integrate[exp(-x^2)]dx,with integration limit (-P2/2+t)/P1<x<(P2/2+t)/P1. Similar case has been discussed for only one set of data. But we have more than 100. So i still need a
little bit details about how to do this for many sets of data.

thanks.
1   L A T E S T    R E P L I E S    (Newest First)
zachary_origin Posted - 04/19/2006 : 07:44:17 AM
Hi,

The convolution can be converted to the fitting functions as follows:


you can define an user-defined function named as "convolute2":

Parameter Names: P1,P2, A, y0
Independent Var: x
Dependent Var: y

the function boby goes like:


//the following lines actually perform a integrate to the function
int nH = 100;//this is the number of steps for integrate
double dH = P2/(double)nH;
double dX;
double dFx = 0;
double dIntegral = 0;
for( int ii = 0 ; ii< nH; ii ++ )
{
dX = x + ii * P2/nH;
dFx = exp( -(dX/P1)^2 );
dIntegrate += dH * dFx;
}
y=y0+A*dIntegral;
//-------------------------------------




Using this function, you can fit one data set through the Advanced Fitting Dialog.

Then you should write another OC function to perform the fitting for every data set.


It can be like this:

void MultiCurveFit()
{
Worksheet wks("Data1");"); //here is the data worksheet name
if(!wks) return;
using NLSF = LabTalk.NLSF;

int nCols = wks.GetNumCols();
Dataset dsFit;
string strName;
for(int ii = 1 ; ii < nCols; ii++) //Col(0) is X
{ //perform fitting for every column
dsFit.Attach( wks, ii );
dsFit.GetName(strName);
NLSF.begin();
NLSF.init();
NLSF.cleanupfitdata();
NLSF.Func$ = "convolute2";
NLSF.fitdata$ = strName;
NLSF.P1=3.0;
NLSF.P2=5.0;
NLSF.P3=2.0;
NLSF.P4=1.0;
NLSF.fit(10); //iterating for 10 times
NLSF.end(1);
LT_execute("rescale()");
dsFit.Detach();
}
}
//---------------------



when it iterates for 10 times, the result is good:


Parameter Value Error
----------------------------------------
P1 4.16934 0.07113
P2 1.46474 0.24861
A 3.09749 0.45967
y0 0.29562 0.00346
----------------------------------------





(If you found you cannot use Origin C in NLSF dialog, please select menu: Help->About Origin to open the dialog box. Check if the version is Origin 7 SR0 or Origin 7 SR1. If so, you need to update your Origin into the higher version (maybe SR4) first. )





Zachary
OriginLab, GZ office.




quote:

Origin Version (Select Help-->About Origin): 7.0
Operating System:windows 2000
actually this is an integration problem which has been discussed before. but i still need some further help.
our data is the convolution results of two functions. one is a gaussian function as y1=A*exp(-(x/P1)^2) and the other one is a square pusle function as y2={(0,x<-P2/2)(1,-P2/2<x<P2/2),(0,x>P2/2)).here A,P1,P2 are parameters to fit. So,our fitting function looks like y3=y0+integration(y1[x]*y2[t-x])dx. (y0 is only for baseline,t is real variable). But i don't know how to write a piecewised function like y2.
Also the result of the integration can be calculated and it is an error function like: Integrate[exp(-x^2)]dx,with integration limit (-P2/2+t)/P1<x<(P2/2+t)/P1. Similar case has been discussed for only one set of data. But we have more than 100. So i still need a
little bit details about how to do this for many sets of data.

thanks.




Edited by - zachary_origin on 04/19/2006 07:47:48 AM

Edited by - zachary_origin on 04/19/2006 07:53:17 AM

Edited by - zachary_origin on 04/30/2006 04:14:09 AM

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