Author |
Topic |
|
jksuh
USA
1 Posts |
Posted - 06/16/2010 : 2:31:15 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): Origin 8 Operating System: Windows XP
Hello everyone and origin experts out there. my name is Kay.
First of all, I have been enjoying Origin and appreciated the software to its fullest haha. thanks developers.
To begin with, what I want to talk about is
I am trying to program my own function to fit data in Origin by utilizing user defined function that allows you to code whatever you want. since the data that I want to analyze follows Lorentiz shape with some asymmetry at the center, I am trying to do fitting data with ASYMMERIC function of Lorentiz.
Thus, my idea is this. Apparently, I got my inspiration of how to code from the description of a symmetric Lorentiz function built in the software. they are similar and I added some of parameter to consider the asymmetricity.
here is my code (I would say it is a code because it is very simple haha) ---------------------------------------------------------------------- this is an independent variable x dependent y
// basically I want to create y that is a function of x
parameters y0,y1,xc,w1,w2,A1,A2
// y0 is left hand side of noise level, y1 is right hand side of noise level, xc is the center of the curve, w1 is left hand side half width at half maximum, w2 is right hand side HWHM, A1 and A2 are the areas of each curve(left half and right half).
// here is the equation. you can simply think about what I am trying to do by looking at it.
y = (1/2)*(2*y0 + (1-(x-xc)/abs(x-xc))*(A1/PI)*(w1/((x-xc)^2 + w1^2)))+(1/2)*(2*y1 + (1-(xc-x)/abs(xc-x))*(A2/PI)*(w2/((x-xc)^2 + w2^2)))
//(x-xc)/abs(x-xc) this part looks peculiar but not really, it gives you just -1 for x-xc>0, 1 for the other case.
InitialValues = --(V),--(V),--(V),--(V),--(V),--(V),--(V),--(V) Meanings = offset,offset,center,width,width,area,area,center LowerBounds = --(I, Off),--(I, Off),--(I, Off),0(X, On),0(X, On),0(I, Off),--(I, Off),--(I, Off) UpperBounds = --(I, Off),--(I, Off),--(I, Off),--(I, Off),--(I, Off),--(I, Off),--(I, Off),--(I, Off) NamingMethod = User-Defined NumberOfSignificantDigits = 0,0,0,0,0,0,0,0
// from now on, this is parameter initialization
xc = peak_pos(x_y_curve, &w1, &y0, NULL, &A1); A1 *= 1.57*w1;
// I dont know how to relate w2, y1, and A2 parameters not being used in the code right above to others. ---------------------------------------------------------------------- I think there is something wrong with the initialization part. but I havent been able to figure out whats wrong. lack of knowledge.......
with the code above, the result of the fitting function is weird it looks bizarre and doesnt seem to be right. (left half part fitting seems alright but right half is I believe wrong)
it would be greatly appreciated if you could help me with this. Thank you so much! have a great day!
hello, it is Kay |
|
larry_lan
China
Posts |
Posted - 06/16/2010 : 10:30:27 PM
|
Hi:
The initial code is just a guess for the fitting parameters, it's not necessary to close to the fitted values. You can adjust the initial values in NLFit dialog during fitting. Maybe you can try:
xc = peak_pos(x_y_curve, &w1, &y0, NULL, &A1);
w2 = w1;
A2 = A1;
y1 = y0; However, if your function type is Origin C, then you should replace (1/2) into (1.0/2) or 0.5, or you won't have correct result. Because C will treat (1/2) as 0.
Thanks Larry OriginLab Technical Services |
|
|
|
Topic |
|
|
|