T O P I C R E V I E W |
5rooms |
Posted - 03/14/2018 : 12:09:15 PM Hi everyone,
I have a question regarding the piecewise fitting of a curve. My peak has to be fitted with a Gaussian profile for values smaller than the maximum and with a Lorentz function bigger than the maximum. I used the tutorial
https://www.originlab.com/doc/Tutorials/UDF-Quote-BuiltInFunc (as quoted in https://my.originlab.com/forum/topic.asp?TOPIC_ID=19647)
to create such a fitting function (I did exactly as described in the tutorial and just changed the second nlf_Gauss to nlf_Lorentz). It works in principle, but the resulting fitting function is no steady (see attached screenshot). How can I fix this problem?

Thank you very much!
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2017G (64-bit) SR2 Operating System: Windows 7 64 bit
|
5 L A T E S T R E P L I E S (Newest First) |
5rooms |
Posted - 03/16/2018 : 06:12:30 AM Thank you so much for your great support, the function works perfectly now! |
AmandaLu |
Posted - 03/16/2018 : 04:23:11 AM Hi Andreas,
Sorry my derivation was wrong. To make yc1 = yc2, the relationship of A2 and A1 should be
A2 = A1*w2*sqrt(pi/2)/w1
Please modify your function body accordingly.
Thanks, Amanda OriginLab Technical Service
|
Hideo Fujii |
Posted - 03/15/2018 : 4:11:26 PM Hi Andreas,
Maybe you can take more straightforward way to share the height of the peak - by using the amplitude version of Gaussian, GaussAmp(x,y0,xc,w1,A), and defining the similar version of Lorentz, that is: LorentzAmp(x,y0,xc,w2,A) = y0+(A*w2^2)/(4*(x-xc)^2+w2^2) I tried, and it seems working:

I hope this helps.
--Hideo Fujii OriginLab |
5rooms |
Posted - 03/15/2018 : 05:58:26 AM Hello Amanda,
thank you very much for your fast and helpful support. I changed the function as you recommended, but the Gaussian and the Lorentz profile still don't connect smoothly even though the position of the maximum is way better now.

I attached a screenshot of the function editor

Just for your information: don't worry about the bad fit between 15000 and 25000, this is something I will take care of later.
Thanks
Andreas |
AmandaLu |
Posted - 03/15/2018 : 02:41:16 AM Hi,
If you want the two segments connect smoothly, you will need to make the two functions connect at center point (xc, yc). That is, yc1 = yc2, in which yc1 = A1/(w*sqrt(pi/(4*ln(2)))), yc2 = 2*A2/(w*pi) So we have A2 = A1*sqrt(ln(2)*pi) Then you can modify the function as follow: Parameters: y0,xc,w1,w2,A1 Function body: double A2 = A1*sqrt(ln(2)*pi); y = x<xc? nlf_Gauss(x, y0, xc, w1, A1) : nlf_Lorentz(x, y0, xc, w2, A2);
The fitting result should be something like:

Thanks, Amanda OriginLab Technical Service
|
|
|