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 for Programming
 Forum for Origin C
 Parameter Initialization Functions and Curve-Fit ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Outboard Bayou

USA
3 Posts

Posted - 03/22/2009 :  10:00:49 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8
Operating System: MS Vista

I have some questions regarding parameter initialization functions when creating user-defined curve fitting functions. I should clarify that I have a student license copy of OriginPro 8. According to the Tips tab, "Functions commonly used for parameter initialization are defined in file <Origin Installation Folder>\OriginC\System\data.h." Apparently my copy of Origin did not come with this file, which would have been useful.

My next question then is how do I set up a parameter initialization for a function of the following form:

y = A*(.15*x+7)^b*exp(C*(.15*x+7)^d*x^e)

I am obviously doing something very wrong because it fails to compile every time. Currently the 'incorrect' parameter initialization appears like this:

sort( x_y_curve );
//smooth( x_y_curve, 2 );
Dataset dx;
x_y_curve.AttachX(dx);
dx = ln(dx);
x_y_curve = ln( x_y_curve );
double coeff[2];
fitpoly( x_y_curve, 1, coeff);
A = exp( coeff[0] );
b = coeff[1];
int sign;
C = get_exponent(x_data, y_data, NULL, &A, &sign);
A = sign * exp(a);
sort( x_y_curve );
//smooth( x_y_curve, 2 );
Dataset dx;
x_y_curve.AttachX(dx);
dx = ln(dx);
x_y_curve = ln( x_y_curve );
double coeff[3];
fitpoly( x_y_curve, 2, coeff);
C = exp( coeff[0] );
d = coeff[1];
e = coeff[2];

The error is probably because the 'd' and 'e' terms should be represented by the A term as well, but I will defer to those who have a more expert opinion.

I was wondering whether the curve-fitting function has to be defined always as y = .... or if it could be defined as ln(y)=... or ln(a*y)=...

Finally, I have a multiple curve data set and would like to share the b, d, and e terms but have individual values of A and C calculated for each curve. Is this possible using the global fit option and how does one actually get a larger version of the small function preview after the data is actually fit? All I obtain is individual curve fits for each set of data but I would prefer to have all the curves superimposed on the same plot just as in the preview plot.

greg

USA
1379 Posts

Posted - 03/23/2009 :  10:25:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There are a few corrections to make ..

One is that case sensitivity is important so
A = sign * exp(a);
should be
A = sign * exp(A);

Also Dataset dx is declared twice.

Another problem is that dynamically declaring double array does not work. Just declare a Dataset and size as needed as in:

sort( x_y_curve );
//smooth( x_y_curve, 2 );
Dataset dx;
x_y_curve.AttachX(dx);
dx = ln(dx);
x_y_curve = ln( x_y_curve );
//double coeff[2]; This does not work so use following
Dataset coeff;
coeff.SetSize(2);
fitpoly( x_y_curve, 1, coeff);
A = exp( coeff[0] );
b = coeff[1];
int sign;
C = get_exponent(x_data, y_data, NULL, &A, &sign);
A = sign * exp(A);
sort( x_y_curve );
//smooth( x_y_curve, 2 );
// Dataset dx; Duplicate
x_y_curve.AttachX(dx);
dx = ln(dx);
x_y_curve = ln( x_y_curve );
//double coeff[3]; This does not work, just resize
coeff.SetSize(3);
fitpoly( x_y_curve, 2, coeff);
C = exp( coeff[0] );
d = coeff[1];
e = coeff[2];
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