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
 NLSF: Fitting different functions for different x

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
Don Alexander Posted - 08/28/2006 : 5:43:25 PM
Origin Version (Select Help-->About Origin): 7.0 or 7.5
Operating System: Windows XP

Dear all, I have a big problem.

I have a function that is defined differently for different ranges of the independent variable x. In essence, something like this:

y = f1(c1,c2,c3;x) for x < a
y = f2(c1,c2,c3;x) for a < x < b
y = f3(c1,c2,c3,R;x) for b < x < c
y = f4(R;x) for c < x < d
y = f5(R;x) for d < x

c1, c2, c3 and R are parameters. a to e are simply values of x, say 0, 2, 4 and 8. The functions are just polynomials or power laws, stuff like:

f1(c1,c2,c3;x) = c1 + c2*x + c3*(0.5[x-1]^2-0.5[x-1]^3)
f5(R;x) = 0.4*x^1.6 - 0.2*x^1.6/R

There are a lot of constants in the functions (if anyone is interested, it's Reichart's merging of the astrophysical dust extinction laws of Fitzpatrick & Massa with Cardelli, Clayton & Mathis) that assure that the different parts of the function join smoothly for realistic values of the parameters.

I could not find anything in the advanced fitting tool where one is able to give different functions for different ranges.

Also, the amount of data points that I am fitting is quite low. While there will be more data points than free parameters for the whole range of x, it is possible that this will not be the case for certain subfunctions in one range. So it is important that the different curves have identical parameters to ensure a smooth fit. this means I cannot just take one subfunction and determine all parameters which will then be fixed for the other cases.

Anyone have a solution?

Thanks a lot!

Alex
3   L A T E S T    R E P L I E S    (Newest First)
zachary_origin Posted - 08/29/2006 : 9:35:41 PM
Hi Alex,

Sure, you can mail me and discuss with the problem via tech@originlab.com or zachary@originlab.com.cn .

You can send the .fdf file, which may locate in the user folder of Origin. E.g. you have defined a function named ABCD and the user folder of Origin is YourName, installation folder of Origin is C:\program files\originlab, then the file path is C:\program files\originlab\YourName\Fitfunc\ABCD.fdf.

Also you can send me your data so that I can try it.

Hope I can do some helps for you.




Zachary
OriginLab GZ Office
Don Alexander Posted - 08/29/2006 : 6:55:21 PM
Hello, Zachary, thanks a lot for the help.

Everything worked out fine until I actually loaded a dataset and tried to use my function. It tells me that there is an error and that the fitting function is not generating values. Furthermore, it does not generate values when you try to simulate the curve!

I have plotted the function in another program and my initial parameters are decent enough to put the curve close to the data. I've used the NLSF with other functions and the results were good even for much higher discrepancies of the initial parameters.

I need to work this out, can we get in contact per mail?? Might make it a little easier than via the forum.

Alex
zachary_origin Posted - 08/28/2006 : 9:55:37 PM
Hi Alex,

You need create an user-defined fitting function. For how to do it, you can see this multimedia tutorial.

http://www.originlab.com/www/support/resultstech.aspx?ID=966&language=English

After you have known how to create user-defined fitting functions, the function body can go like this:


Parameters: c1,c2,c3,R
Independent variable: x
Dependent variable: y
 
double a = 2.0, b=4.0, c=5.0, d = 6.0;
if( x < a)
y = c1 + c2*x + c3*(0.5*(x-1)^2.0-0.5*(x-1)^3.0);


else if(a <= x && x < b)
y = c1 + c2*x + c3*(0.5*(x-1)^2.0-0.5*(x-1)^3.0);//f2(c1,c2,c3;x) here
else if(b <= x && x < c)
y = c1 + c2*x + c3*(0.5*(x-1)^2.0-0.5*(x-1)^3.0) + R;//f3(c1,c2,c3,R;x) here
else if(c <= x && x < d)
y = R*x ;//f4(R;x) here
else //if(d <= x)

y = 0.4*x^1.6 - 0.2*x^1.6/R; //f5(R;x) here





The problem is very similar with this post, http://www.originlab.com/forum/topic.asp?TOPIC_ID=5047
you can take a look at this.

Zachary
OriginLab GZ Office

Edited by - zachary_origin on 08/31/2006 03:33:21 AM

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