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
 Fitting two curves simultaneously
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

a_user

USA
0 Posts

Posted - 08/18/1998 :  4:47:00 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I'm a potential buyer of Origin but there is one thing I would like to know
whether Origin can actually do for me. I have data that
should fit two equations that depend on the same variables.

It could be as simple as:
y1=a*x+b*x^2
y2=a+b*x
(In real life it is a LOT more complicated).

a and b above should be found at the same time in what I call a simultaneous
fit. I'm not interested in fitting y1 then y2 and compare the
values found for a and b. Can this type of fit be made in Origin?
(For instance by writing code in LabTalk.)

Guest

a_user

USA
0 Posts

Posted - 08/18/1998 :  4:49:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Fitting multiple datasets with common parameters

Origin's Non-linear Curve Fitter allows you to fit datasets using single or multiple independent or dependent variables.
In your example you would want to fit using multiple dependent variables.
To do this, you should have two datasets (representing your Y1 and Y2) plotted against the same X dataset. Assuming your Origin Worksheet is called Data1 and looks like:

A(X) B(Y) C(Y)

...here is the procedure:

1.Plot the data by highlighting your Y1 and Y2 column and selecting a graph type from the Plot menu. 2.Open the fitter by selecting Analysis:Non-linear Curve Fit from the menu.
(I will assume the Fitter is in Basic mode.) 3.Click New to define a new function.
(These instructions apply to the Define New Function dialog.)
4.Give your function a short, descriptive name and select Equations from the Form combobox. 5.Check the User Defined Param. names box and enter a,b for the Parameter Names. 6.Change the Dependent Var. box to y,z (or some other names that will match your definition). 7.In the large text box enter your function definitions:

y=a*x+b*x^2;
z=a+b*x:

(Y1 and Y2 have special meaning to Origin so I did not use those names.) 8.Click the Save button, then click Accept.
(The Fitter returns to the Select Function dialog.) 9.Click Select Dataset (The Fitter opens the Select Dataset dialog.) 10.Select y Dep in the Variables box 11.Select data1_b in the Available Datasets box 12.Click Assign (The data1_a dataset should automatically be assigned as the independent dataset.) 13.Select z Dep in the Variables box 14.Select data1_c in the Available Datasets box 15.Click Assign 16.Click Start Fitting (The Fitter will open the Fitting Session dialog.) 17.Enter some reasonable numbers for a and b 18.Click Chi-Sqr to verify that you've done everything correctly - a value of Chi-Sqr should appear 19.Click the 10 Iter button until Chi-Sqr no longer changes in value then click Done

The Fitter generates results and (optionally) puts a label on your plot with the results.

Go to Top of Page

a_user

USA
0 Posts

Posted - 08/18/1998 :  4:50:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Just fitting one curve?

Dear Greg D'Unger

I have tested your suggestions on a version of Origin I have access to. I have
a few questions:

You state that I should enter:

y=a*x+b*x^2;
z=a+b*x: <- should this not be a semicolon?

When I start to fit these simple equations it stilll seems as if Origin only
fits to the first of the two functions. When Origin plots the fitted curves
together with the data points only one of the sets will appear to be correct.
(The one entered first in the text box under New Function). This is of course
very worrying since the aim of the game is that Origin uses both data sets to
find a and b.

I suspect that this problem might be related to the problem with the
colon/semicolon in the definition of the functions.

Guest

Go to Top of Page

a_user

USA
0 Posts

Posted - 08/18/1998 :  4:51:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
More about ... Just Fitting One Curve?

You are correct that the final character in the definition should be a semicolon. The definition in my example should read:

y=a*x+b*x^2;
z=a+b*x;

With this correction, the example should work in both Origin 4.1 and Origin 5.0.
There is a general problem in drawing additional Independent and Dependent datasets. Thus, while the first Dependent dataset is drawn correctly in the example, the second is drawn incorrectly although the parameters are still correct.
To get the correct display, you need to modify the fitted dataset:

Origin 4.1

1.Double-Click on the second fitted line (the horizontal line in our example). 2.Click the Worksheet button 3.Highlight the B(Y) column and select Column:Set Column Values from the menu 4.Enter a+b*col(A) as the formula and click Do It

The correct values of a and b will used to calculate a+b*x and the plot will update
Origin 5.0

1.Double-Click on the second fitted line (the horizontal line in our example). 2.Click the Worksheet button 3.Right-Click on the B1(Y2) column in the NLSF worksheet and select Set Column Values from the context menu 4.Enter a+b*col(A1) as the formula and click Do It

The correct values of a and b will used to calculate a+b*x and the plot will update A similar drawing problem occurs when fitting with multiple Independent variables. The second (third, etc.) dataset must be updated with the correct equation.

Go to Top of Page

a_user

USA
0 Posts

Posted - 08/18/1998 :  4:56:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
drawing problem with multiple independent variables

I have seen this problem with the incorrect drawing too. But sometimes it DOES
work, although I have not been able to identify when it will and wont work.

The suggested fix is not always appropriate, for instance with functions that
must be evaluated by using a complicated script using loops etc. This is often
the case with many functions that origin does not support (for instance I am
now
working with the fresnel sine and cosine functions). These complicated scripts
CAN be executed by the fitter, but the set column values, or script window
function definition (F(X)=...) routines CANT handle them. So what now?

I wonder if microcal is fixxing this problem? A patch would be MOST welcome.
This problem was first noted in version 4, and I recently ascertained that it
still is a bug in ver 5.0.

Go to Top of Page

a_user

USA
0 Posts

Posted - 08/18/1998 :  4:57:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This problem is fixed in Origin 5.0 SR1

The problem with the 2nd (3rd, etc.) of multiple independent or dependent datasets being assigned incorrectly even though the function parameters are calculated correctly has been fixed in the patch to Origin 5.0 that is available on our Web site at:
Technical Services in the Tech Downloads area.

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