Author |
Topic  |
|
nevermind
USA
1 Posts |
Posted - 02/21/2002 : 2:28:41 PM
|
I am new to Origin. I wish you guys wouldn't laugh at my simple question: I have a dataset of a closed curve. How can I define a parametered function to fit it? Can I define such a function as: x=f(a,b,t); y=g(a,b,t); where a ,b are parameters and t is a dumb variable? for example: x=a*cos(t); y=b*sin(t); is a ellips. Thank you very much. I need this urgently. |
|
rtoomey
USA
184 Posts |
Posted - 02/22/2002 : 3:17:04 PM
|
Origin's Nonlinear Curve Fitter is not equipped to handle parametric equations. However, it is most certainly a feature worth looking into. I have entered a suggestion in our database to add such a feature.
Sincerely, Ryan Toomey Technical Support OriginLab Corporation
|
 |
|
Hideo Fujii
USA
1582 Posts |
Posted - 03/12/2002 : 1:29:38 PM
|
Because of lack of my understanding, you can teach me...
Can we independently fit each parametric function such as x=a*cos(Xt) individually??? If there are interactions between x and y such as x=f(x,y,t) and y=g(a,b,t), we can do the simulteneous fitting by sharing parameters a and b... Once you get the parameter estimation, you can produce data points for plotting, then plot them....Probably, I am missing some important points...
Edited by - hideo fujii on 03/12/2002 13:34:35
Edited by - hideo fujii on 03/12/2002 16:38:16 |
 |
|
cpyang
USA
1406 Posts |
Posted - 03/12/2002 : 11:14:22 PM
|
Yes, this problem is the case of multiple dependent variables that is supported in Origin, so you are basically looking at
y = a*f(c,d,x) + b*g(c,d,x);
and you can setup sharing of c and d and fix a=0 for Y1 dataset and b=0 for Y2 dataset. The resulting fit curves can then be plotted as Y2 vs Y1 with the x in the range of the dump parameter.
This type of situation will be made much easier with Origin C in Origin 7, since you can independently define the f and g function above in the CodeBuilder interface in a separate C file as, for example
double g(double c, double d, double x) { y = d; y+= c * cos(x); return y; }
Edited by - cpyang on 03/13/2002 08:25:37 |
 |
|
nadi
Canada
Posts |
Posted - 09/07/2004 : 4:16:17 PM
|
A while has past since these replies have been written. I now have Origin 7 and I am confronted with a similar problem: that of fitting a data set with an equation that can only be expressed as 2 parametric equations:
x=f(a1,t) y=g(a2,t)
(Normally, I would've isolated t in equation (1) and substituted its value in equation (2) to have an equation expressed as y = g(a1, a2, x), but in my case, t could not be isolated.
where t is the "dump" or the "dummy" variable that I do not know; a1 and a2 are the parameters I am interested in. My data set is expressed as (x,y) values.
What is the best solution to tackle this problem ? If it is using Origin C, as suggested by cpyang then what would be the correct syntax to define t ?
Thank you very much ! |
 |
|
easwar
USA
1965 Posts |
Posted - 09/07/2004 : 5:59:46 PM
|
Hello,
There is no direct way to fit parametric equations such as yours in Origin.
However, there could be a "work around" such as in the simple example below:
Say we want to fit an ellipse with equation such as: x=a*cos(t); y=b*sin(t); where the objective is to extract the values of a and b as parameters of the fit.
Let us start with the trivial example of having all three datasets t, x, and y, and fitting this in Origin:
1> Open a new worksheet and set it up with three columns 2> Rename the column names as t, x, y 3> Set col types to be Y, X, Y 4> Use "set col values" dialog, on the three columns, and set their values as follows, for rows 1 thru 64 for all: col(t) = (i - 1 )*0.1 col(x) = 10 * cos( col(1) ) col(y) = 5 * sin( col(1) ) 5> At this point, highlight the third col and plot, you will see an ellipse (if you don't, your angular units in Tools->Options->Numeric tab need to be changed to rad) 6> Bring up the NLSF tool and define a new function: Name: ellipse1 check User Defined Param Names checkbox In Parameter Names edit box, enter: a,b In Indep Var edit box, enter: t In Dep vars edit box, enter: x,y In the function edit box, enter: x = a * cos( t ); y = b * sin( t ); Leave the "Use Origin C" checkbox checked Go to Function menu of NLSF tool and save your function 7> Go to the Action->Dataset menu of NLSF and assign: data1_t -> t (Indep) data1_x -> x (Dep) data1_y -> y (Dep) 8> Note that the graph you created in step 4> will change to show two data plots that look like sine and cosine curves. NLSF does not plot the two dep vars against each other, but rather forces you to work with dep vars plotted agains the indep var t. This is fine. Although the graph does not look any more like an ellipse, the fit will proceed fine. You may have to rescale the graph. 9> Go to the Action->Fit page in NLSF and enter value of 5 for both a and b. Then click the Chi-Sq button at the bottom. You will see two red curves on the graph - somewhat close to the data. 10> Click the 100Iter button and you should get converged values of a=10 and b=5, which are the exact values used to create the data. 11> Click the Done button to finish this fit.
Now, the above is trivial - the t dataset was "given' to Origin and was used directly as the indep var. for the fit.
In your case, you do not have the t dataset. In such a situation, the only workaround I can think of is to "create" a t dataset and use that in the fitting process, such as below:
12> Go to col(t) and fill it just with row numbers. So essentially you are throwing away the information in the t dataset. In other words, you will now just use row numbers as your t dataset. 13> Create a new graph by using thrid column - you will see ellipse again 13> Go to Action->Reset menu item in NLSF and restart the fitter 14> Select your previous function again, and modify as follows" In Parameter Names edit box, enter: a,b,p1,p2 In Indep Var edit box, enter: t In Dep vars edit box, enter: x,y In the function edit box, enter: double temp = p1 * t + p2; x = a * cos( temp ); y = b * sin( temp ); Leave the "Use Origin C" checkbox checked 15> Assign datasets again as under step 7>. Graph will again change to 2 curves. 16> Go to Action->Fit and assign initial guess values as follows: a = 5 b = 5 p1 = 0.1 p2 = 1 17> Click Chi-Sq button and then the 100Iter button. You should get a perfect fit and parameter values of a=10, b=5, p1=0.1, p2=-0.1
So essentially what I did here was to "generate" the t dataset using a linear transformation of row numbers, and then use that in the fitting process as the independent dataset.
This example is of course trivial. In this case, my original t column had (i-1)*0.1 and so I "knew" that I can generate a fake t datset using t = p1 * i + p2 and that worked.
Now, in your case, with real life data, is this possible? Not sure. You could try some simple transformation equations to generate t and fit the data and see if that works?
The general problem of fitting with parametric equations is not trivial, and I am not sure if this can even be done with (Levenberg-Marquardt) minimization techniques. See this forum post for example: http://www.math.rwth-aachen.de/mapleAnswers/html/693.html Posters are suggesting to turn the equations around to a linear regression problem and fit. But except in the case of trivial equations such as ellipse, that may not be practical/possible.
Easwar OriginLab
|
 |
|
|
Topic  |
|
|
|