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
 Fit Convolution
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Piasecki

Poland
Posts

Posted - 01/14/2022 :  08:25:58 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: Origin 2022-Pro Sr1 9.9.0.225 (Academic), Win 10

Concerning the Fit Convolution appl.: is it possible to add to the fitted function (e.g. Gaussian + Lorenzian) the condition of some cut off, e.g. f(x) = 0 for x < 0? Of course, this condition should not apply to the signal (resolution function), nor to the data.

YimingChen

995 Posts

Posted - 01/14/2022 :  10:54:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The app only allows function expression. You may want to check this tutorial page on defining convolution function with Origin C code:
https://www.originlab.com/doc/en/Tutorials/Fitting-Convolution

James
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/14/2022 :  11:57:38 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you, but this I know.
Unfortunately, I don't know nor C language, neither LabTalk.
I know that e.g. for the Gaussian + Lorentzian the function is defined as:
f(x) = A*exp( -(4*ln(2)*(x-xc)^2)/w1^2 )*(1-Sign(x-xc))/2.0 + A*(w2^2/(4*(x-xc)^2 + w2^2))*( 1+Sign(x-xc) )/2.0

Could you please tell me how to modify this expression by introducing the cut
f(x) = 0 for x < 0 or more generally for x < xcut ?
Go to Top of Page

YimingChen

995 Posts

Posted - 01/14/2022 :  3:35:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK, here is the way to go:
1. Launch the Fit Convolution app, and make the settings as shown below and click Save as... to save the fitting function to myConv. Here we only declare the func(A, xc, w1, w2, x) and we will define it later.


2. Close the app, choose from menu Tools:Fitting function builder..., choose Edit a User-defined Function, select myConv. Keep click Next button until the Origin C Fitting Function page. Click the button to open Code Builder.



3. Add the code below to the fitting function file. Click Compile button, then click Return to Dialog.

double func(double A, double xc, double w1, double w2, double x) {
	if (x < 0) {
		return 0;
	} else {
		return  A*exp( -(4*ln(2)*(x-xc)^2)/w1^2 )*(1-Sign(x-xc))/2.0 + A*(w2^2/(4*(x-xc)^2 + w2^2))*( 1+Sign(x-xc) )/2.0;
	}
}




4. Click Finish button. Then the fitting function it built.
Go to Top of Page

YimingChen

995 Posts

Posted - 01/14/2022 :  3:43:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
To fit the data, select col(B) and go to menu Analysis->Fitting->Nonlinear Curve Fit... Pick the fitting function myConv, and run the fit.

I attached the fitting function here.

https://my.originlab.com/ftp/forum_and_kbase/Images/myConv.FDF

James

Edited by - YimingChen on 01/14/2022 3:45:27 PM
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/15/2022 :  04:08:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot, but this is a different situation than in my case, as here the data are evidently cut at some X value, so you can find the appropriate fitting function f(x).
In my case, the situation is different: the cut is certainly present because of the conservation energy law, so all part of the observed distribution to the left of the cut is due to the resolution effects, thus it cannot be seen in the solution, i.e. in the fitting function.

Somehow I cannot find here the way of attaching the figure nor data. I can send them to you if you tell me how.

Eryk
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/15/2022 :  05:31:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
PS I cannot open the link https://my.originlab.com/ftp/forum_and_kbase/Images/myConv.FDF
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/15/2022 :  12:19:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
Thanks a lot for your recipe!
I tried to follow it, but the compilation failed and I am unable to find the error.
I would like to send you the printscreen, but I don't know how to attach the file. Help, pls.

Best regards
Eryk
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/17/2022 :  12:57:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is the prntscr

Go to Top of Page

YimingChen

995 Posts

Posted - 01/17/2022 :  09:07:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
For the compiling error, you need to define the function func() outside _nlsfmyConv(). Thanks.

James
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/17/2022 :  09:58:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I believe I did it many times.

If "add the code below the fitting function file" means: below the
CONVOLUTION( func(A, xc, w1, w2, x), h(x) )

then I did it already many times, with the same error.

If you mean anything else, please explain precisely what you mean by "defining the function func() outside _nlsfmyConv().

Thank you.
Eryk
Go to Top of Page

YimingChen

995 Posts

Posted - 01/17/2022 :  10:30:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Right now your func() is defined within _nlsfmyConv() function. Can you move the function before the FitConvolutionModel(ARGS2) function as I already showed in the figure?



James
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/17/2022 :  11:07:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, apparently now it is compiled, but after Return to Dialog cannot click the Finish button, since it is shadowed (see attachment).

What should I do?
Eryk
Go to Top of Page

YimingChen

995 Posts

Posted - 01/17/2022 :  11:18:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Click Next button until the Finish button is enabled.
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/17/2022 :  11:27:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Should I put initial values before compilation?
Go to Top of Page

YimingChen

995 Posts

Posted - 01/17/2022 :  11:58:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It shouldn't matter when you set the initial values.
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/17/2022 :  12:04:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Great. Unfortunately, I don't see any reaction of the initial distribution (in red) on the parameter setting. Should I?
I am asking this since for the moment the iterations cannot result in finding solution, probably by the improper initial parameters setting.

E.

Go to Top of Page

YimingChen

995 Posts

Posted - 01/17/2022 :  2:03:12 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
In the NLFit dialog, you can select Fitted Curves in the left panel, and in the right panel, set X data Type to same as Input Data. See if it helps.

Otherwise, you can try different initial parameters.

James
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/17/2022 :  4:23:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If I understand what you have in mind, I presume that"Fitted curves" on the left panel ARE selected (see attachment), however I don't know where is the 2nd panel.

Eryk
Go to Top of Page

YimingChen

995 Posts

Posted - 01/17/2022 :  4:34:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This is what I meant
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/17/2022 :  5:12:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, it partly helps, at least one can see some peak (see att.), but it still doesn't react on the parameter's changes. Eg. here initial xc = 2, but on the plot it is at 12 and is there frozen....

Eryk
Go to Top of Page

YimingChen

995 Posts

Posted - 01/18/2022 :  10:10:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Make sure you have the response data saved in col(C). See the tutorial page.
https://www.originlab.com/doc/tutorials/fitting-convolution

James
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/18/2022 :  10:55:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, as always (see attachment)

Eryk
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/18/2022 :  11:00:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Since I'm not sure whether i sent the attachments, I do it again.

Erykhttps://my.originlab.com/ftp/forum_and_kbase/Images/formulaA.txt
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/18/2022 :  11:03:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
For some reasons I don't see one of 2 att.https://my.originlab.com/ftp/forum_and_kbase/Images/Book47B.ogwu
Go to Top of Page

Piasecki

Poland
Posts

Posted - 01/19/2022 :  2:40:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Unfortunately, my attempts are not successful, the iterations finish without converging. Perhaps the initial parameter values are bad, or the function is not good.
Unfortunately, the visualization of the function with initial parameters (the red line in the figure above) is in complete disagreement with the parameters. Anybody knows why???

Eryk

Edited by - Piasecki on 01/19/2022 2:52:26 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