Descriptive statistics

Origin provides several X-Functions to compute descriptive statistics, some of the most common are:

Name Brief Description
colstats Columnwise statistics
(Pro Only)
Correlation Coefficient
freqcounts Frequency counts of a data set.
(Pro Only)
Compute descriptive statistics on a matrix
rowstats Statistics of a row of data
stats Treat selected columns as a complete dataset; compute statistics of the dataset.

For a full description of each of these X-Functions and its inputs and outputs, please see the Descriptive Statistics.

Descriptive Statistics on Columns and Rows

The colstats X-Function can perform statistics on columns. By default, it outputs the mean, the standard deviation, the number of data points and the median of each input column. But you can customize the output by assigning different values to the variables. In the following example, colstats is used to calculate the means, the standard deviations, the standard errors of the means, and the medians of four columns.

//Import a sample data with four columns
fname$ = system.path.program$ + "Samples\Statistics\nitrogen_raw.txt";

//Perform statistics on column 1 to 4
colstats irng:=1:4 sem:=<new> n:=<none>;

The rowstats X-Function can be used in a similar way. The following example calculates the means of the active worksheet; the results are placed in a new added column at the first of the worksheet.

Note: mean and sd are defaulted to be <new> in output, if not needed, set to <none>.
fname$ = system.path.program$ + "Samples\Statistics\engine.txt";
impasc; //Import a sample data

wunstackcol irng1:=1 irng2:=2; //Unstack columns
wtranspose type:=all ow:=<new>; //Transpose worksheet
range rr1 = 1:2;
delete rr1;
range rr2 = 2;
delete rr2; //delete empty columns
int nn = wks.ncols;
wks.col$(nn+1).lname$ = Mean;
wks.col$(nn+1).index = 2; //Add mean column
wks.col$(nn+2).lname$ = Sum;
wks.col$(nn+2).index = 3; //Add sum column

//Row statistics to get sum and average, saved to corresponding column.
rowstats irng:=4[1]:end[end] sum:=3 mean:=2 sd:=<none>;

Frequency Count

If you want to calculate the frequency counts of a range of data, use the freqcounts X-Function.

//Open a sample workbook
%a = system.path.program$ + "Samples\Statistics\Body.ogw";
doc -a %a;

//Count the frequency of the data in column 4
freqcounts irng:=4 min:=35 max:=75 stepby:=increment intervals:=5;

Correlation Coefficient

corrcoef X-Function can be used to compute the correlation coefficient between two datasets.

//import a sample data
fname$ = system.path.program$ + "Samples\Statistics\automobile.dat";

//Correlation Coefficient
corrcoef irng:= (col(c):col(g)) rt:= <new name:=corr>