📄 data.h
字号:
initNLSF, fitpoly, fitpoly_range
*/
//BOOL fitNLSF(NLSFCntrl &control); // Use the Origin C NLSF control structure to fit a data set.
/** >Analysis
Fit a data set having to pass only a small set of parameters.
Sample Data:
2 10.54362
4 8.85013
6 7.51005
8 6.23363
10 5.31886
12 5.04538
14 5.47292
16 5.6315
18 5.09736
20 4.94923
22 5.10317
24 5.02472
Example:
// Assumes Sample Data are in Data1_A and Data1_B
string strYData = "Data1_B";
string strFitFunc = "ExpDec1";
fitNLSF(strYData,strFitFunc);
LT_execute("layer -a"); // Rescale graph to show all points
Parameters:
strYData=Input name of Y data set to fit
strFitFunc=Input name of NLSF fitting function
iwType=Input weighting type or method: no weighting (default 0), instrumental or weight by error bars (1),
statistical (2), and arbitrary or weight by data set (3)
strWtData=Input name of weighting data set when iwType is 3
Return:
Returns the Chi-Square value.
SeeAlso:
fitpoly, fitpoly_range, initNLSF
*/
//double fitNLSF(string strYData, string strFitFunc, int iwType=0, string strWtData=''); // Fit a data set having to pass only a small set of parameters.
/** >Analysis
Get the value of Y at a horizontal asymptote. If the asymptote has two branches then Y is defined as
Y = (yatxmax+yatxmin)/2 and if the asymptote has a single branch then Y is defined as either yatxmax
or yatxmin depending on where the slope of the curve is closest to zero.
Sample Data:
-20 -3.04762
-14 -3.06667
-8 -3.11111
-2 -3.33333
-1 -3.5
0 -4
1 --
2 -2
3 -2.5
4 -2.66667
10 -2.88889
16 -2.93333
22 -2.95238
Example:
// Assumes Data1_A and Data1_B exist and contain the Sample Data
Curve crv("Data1_A","Data1_B");
double dYatHA = yatasymt(crv);
printf("The value of Y at the Horizontal Asymptote is %g",dYatHA);
Parameters:
crv=Input curve whose asymptote is found
Return:
Returns the value of Y at a horizontal asymptote.
SeeAlso:
xatasymt, yatxmax, yatxmin
*/
double yatasymt(Curve &crv); // Get the value of Y at a horizontal asymptote.
/** >Analysis
Get the value of X at a vertical asymptote. If the asymptote has two branches then X is defined as
X = (xatymax+xatymin)/2 and if the asymptote has a single branch then X is defined as either xatymax
or xatymin depending on where the reciprocal of the slope of the curve is closest to zero.
Sample Data:
-20 -3.04762
-14 -3.06667
-8 -3.11111
-2 -3.33333
-1 -3.5
0 -4
1 --
2 -2
3 -2.5
4 -2.66667
10 -2.88889
16 -2.93333
22 -2.95238
Example:
// Assumes Data1_A and Data1_B exist and contain the Sample Data
Curve crv("Data1_A","Data1_B");
double dXatVA = xatasymt(crv);
printf("The value of X at the Vertical Asymptote is %g",dXatVA);
Parameters:
crv=Input curve whose asymptote is found
Return:
Returns the value of X at a vertical asymptote.
SeeAlso:
yatasymt, xatymax, xatymin
*/
double xatasymt(Curve &crv); // Get the value of X at a vertical asymptote.
/** >Analysis
Fit a polynomial equation to a range of a curve and return the parameter coefficients.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double coeff[3];
fitpoly_range(crv, 0, crv.GetUpperBound(), 2, &coeff); // Fit 2nd degree polynomial to entire curve
Parameters:
crv=Input curve to fit
ibeg=Input beginning index to fit
iend=Input ending index to fit
ipolyorder=Input degree of polynomial equation
coeff=Output array containing parameter coefficients
Return:
Returns TRUE on success and FALSE on failure.
SeeAlso:
fitpoly, initNLSF, fitNLSF
*/
BOOL fitpoly_range(Curve &crv, int ibeg, int iend, int ipolyorder, double *coeff); // Fit a polynomial equation to a range of a curve.
/** >Analysis
Get the value of Y at the minimum X value of a curve.
Example:
// Assumes Data1_A and Data1_B exist and contain data
Curve crv("Data1_A","Data1_B");
double dYatXmin = yatxmin(crv);
printf("Value of Y at minimum X is %g", dYatXmin);
Parameters:
crv=Input Origin C Curve object
Return:
Returns the value of Y at the minimum X value of a curve.
SeeAlso:
xatymin, xatymax, yatxmax, xaty50
*/
double yatxmin(Curve &crv); // Get the value of Y at the minimum X value of a curve.
//////////////////////////////////////////////////////////////////////////////
// The following are internal Origin functions related to Datasets and Curves
//////////////////////////////////////////////////////////////////////////////
#pragma dll(@OK) // Assoicate all functions below to Origin OK dll
/** >Statistics
Compute basic summary (descriptive) statistics on an Origin data set.
Example:
int iSize;
Dataset dsDataIn("Data1_B");
iSize=dsDataIn.GetSize();
Dataset dsSumOfDataIn("Data1_C");
dsSumOfDataIn.SetSize(iSize);
BasicStats bsStat;
Data_sum( &dsDataIn, &bsStat, &dsSumOfDataIn );
printf( "Min = %f\nMax = %f\nMean = %f\nSD = %f\nTotal = %f\nSSDM = %f\nN = %d\nMissing = %d\niMax = %d\niMin = %d",
bsStat.min, bsStat.max, bsStat.mean, bsStat.sd, bsStat.total, bsStat.ssdm,
bsStat.N, bsStat.Missing, bsStat.iMax, bsStat.iMin );
Parameters:
pdsData=Pointer to input dataset
pbsStat=Pointer to returned BasicStats structure (see OC_types.h)
pdsSumData=Pointer to returned dataset containing cumulative sum
Return:
Returns TRUE, a BasicStats structure (see OC_types.h), and if specified, a data set containing
a cumulative sum of the input data set on success and returns FALSE on failure.
*/
BOOL Data_sum(Dataset* pdsData, BasicStats* pbsStat, Dataset* pdsSumData=NULL); // Dataset basic summary (descriptive) statistics.
/** >Statistics
Calculate percentiles at given percent values for the given dataset.
Example:
// Assumes Data1_A exists in Origin and contains data
Dataset dsA( "Data1_A" );
double dPercent = 50, dPercentile;
Data_percentiles( &dsA, &dPercent, &dPercentile, 1 );
printf( "The 50th percentile is %g\n", dPercentile );
double ardPercents[3] = { 5, 25, 95 };
double ardPercentiles[3];
Data_percentiles( &dsA, ardPercents, ardPercentiles, 3, TRUE );
for(int ii = 0; ii < 3; ii++ )
printf( "The %gth percentile is %g\n", ardPercents[ii], ardPercentiles[ii] );
Parameters:
pdsData=Input Dataset for which percentiles are computed
ardPercents=Input array of percents at which percentiles are computed
ardPercentiles=Output array of percentiles
nValues=Input number of percentile values to compute
bInterpolate=Input flag indicating whether or not to average (interpolate) when needed such as when computing
the 50th percentile for an even number of data values
Return:
Returns TRUE on success and FALSE on failure.
*/
BOOL Data_percentiles(Dataset* pdsData, const double ardPercents[], double ardPercentiles[], int nValues, BOOL bInterpolate=FALSE); // Calculate percentiles at given percent values for the given dataset.
/** >Analysis
Function to sort a data set inplace.
Examples:
int iSize;
Dataset dsRawDATA("Data1_A");
iSize=dsRawDATA.GetSize();
Dataset dsSortedDATA(dsRawDATA); // Create temporary copy of raw data
Data_sort(&dsSortedDATA); // Sort temporary dataset
vector<double> vSortedDATA; // Create dynamic structure to hold sorted data
vSortedDATA.SetSize(iSize); // Dynamically set size of vector
vSortedDATA=dsSortedDATA; // Assign sorted datset to vector
dsRawDATA.Detach();
dsSortedDATA.Detach();
Parameters:
pdsData=Pointer to dataset
bDescending=If TRUE sort in descending order otherwise sort in ascending order (default)
bMissingAsMin=If TRUE evaluate Origin missing values as smallest value otherwise as largest value (default)
Returns:
If successful returns TRUE and a sorted dataset otherwise returns FALSE.
*/
BOOL Data_sort(Dataset* pdsData, BOOL bDescending = FALSE, BOOL bMissingAsMin = FALSE); // Function to sort a data set inplace.
/** >Analysis
Table lookup with interpolation from two data sets (X and Y) of monotonic data. To find the y
value at a given row number pass the Y data set but pass NULL for the X data set. To find the y value
at a given x value pass the Y data set and the X data set. To find the row number of a given y value
pass a data set containing row numbers as the Y data set and pass the Y data set as the X data set.
Function Data_list provides table lookup without interpolation.
SampleData:
A B C
10 2 1
20 4 2
30 6 3
Example:
double Xval, Yval, RowNumber;
// To find Y value at given row number pass desired row number in place of X value and specify
// NULL for X data set (Data_table will interpolate for fractional row numbers)
RowNumber=2;
Dataset dsYData("Data1_B");
Yval=Data_table(RowNumber,&dsYData,NULL);
printf("\nData1_B at row number %f = %f",RowNumber,Yval);
// To find Y value at given X value pass X value and specify X data set (Data_table will interpolate
// for all X values)
Xval=25;
Dataset dsXData("Data1_A");
Yval=Data_table(Xval, &dsYData, &dsXData);
printf("\nData1_B at X = %f is %f",Xval,Yval);
// To find row number of given Y value, pass Y value in place of X value, specify Y data set as X data set, and
// pass a data set containing row numbers {1,2,3,4...} for Y data set (Data_table will interpolate to fractional
// row numbers)
Yval=4.5;
Dataset dsRowNums("Data1_C");
RowNumber=Data_table(Yval, &dsRowNums, &dsYData);
printf("\nRow Number where Data1_B = %f is %f",Yval,RowNumber);
Parameters:
dX=The index value used to perform the lookup
pdsYdata=The Y data set
pdsXdata=The X data set
Return:
Returns the interpolated lookup value from two sets of monotonic data.
SeeAlso:
Data_list
*/
double Data_table(double dX, Dataset* pdsYdata, Dataset* pdsXdata = NULL); // Table lookup with interpolation.
/** >Analysis
Search for the first occurrence of a given value in a data set.
Example:
Dataset dsDataIn("Data1_A");
dsDataIn.SetSize(4);
dsDataIn[0]=0.28019;
dsDataIn[1]=0.93577;
dsDataIn[2]=0.81075;
dsDataIn[3]=0.04418;
double tol, v1, v2;
int nrow;
v1=0.81075;
nrow=Data_list(v1, &dsDataIn); // use default precision
printf("\nnrow = %d",nrow);
v1=0.82;
v2=dsDataIn[2];
tol=fabs((v2-v1)/(fabs(v1)+fabs(v2)));
printf("\ntol = %f",tol);
nrow=Data_list(v1, &dsDataIn, 2); // tol is < 10^-2 so select row 2
printf("\nnrow = %d",nrow);
nrow=Data_list(v1, &dsDataIn, 3); // tol is not < 10^-3 so don't select row 2
printf("\nnrow = %d",nrow);
Parameters:
dX=Value to lookup
pdsData=Dataset to look in for value
nPrecision=Indicates precision to use when determining if the given x value matches a value in the
data set. Pass -1 to use Origin's default internal double comparison precision as specified by the @ND
system variable. Otherwise, pass a positive integer to specify precision (significant digits). When
either the x or the data set value is non-zero, the following condition indicates whether or not a match
has been found: abs((v2-v1)/(abs(v1)+abs(v2))) < 10^(-nPrecision).
Return:
Returns the row index of the first occurence of a given value found in a data set. Returns -1 if
value is not found.
SeeAlso:
Data_table
*/
int Data_list(double dX, Dataset* pdsData, int nPrecision = 8); // Find first occurrence of value in data set.
/** >Analysis
Integrate the given Curve relative to the X axis unless a baseline is specified.
SampleData:
A B C D (column D is returned by Example)
2 5 2 --
4 5 2 6
6 5 2 12
8 5 2 18
Example:
BOOL bErr;
Curve crvMyCurve( "Data1_A", "Data1_B" ); // Create Curve object to integrate
Curve crvMyBaseline( "Data1_A", "Data1_C" ); // Create Curve object of integration baseline
IntegrationResult irMyResults; // Origin C structure to store integration results
Dataset dsCumIntRes( "Data1_D" ); // Cumulative integration result
dsCumIntRes.SetSize( crvMyCurve.GetSize() ); // Set size of dsCumIntRes to size of cvMyCurve
bErr = Curve_integrate( &crvMyCurve, &irMyResults, &crvMyBaseline, &dsCumIntRes, TRUE ); // Perform integration
printf( "Area = %f\n", irMyResults.Area );
Parameters:
pcrvData=Pointer to Curve to integrate
pirResult=Pointer to IntegrationResult structure (see OC_types.h)
pcrvBaseline=Pointer to baseline Curve
pdsIntegral=Pointer to Dataset holding cumulative integration result
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -