3.5.3.1.31 Ss


Description

The ss function returns the sum of the square of individual values in vd minus some reference value. The function ss is defined by the following equation:

ss = \sum_{i=1}^\mathit{N}(data[i]-ref)^2

Syntax

//If ref is a constant 
double sumSquares = ss(dataset vd[, double ref]);

//If ref is a vector
double sumSquares = ss(dataset vd[, dataset ref]);

//If ref is a function
double sumSquares = ss(dataset vd[, string ref]);

Parameter

vd

can be a dataset, or a column in Origin worksheet.

ref

the reference value you want to subtract from vd.
  • If ref is not specified the function defaults to using the mean of vd as the value of ref.
  • ref can be a constant, a dataset, or a function (see examples below).

Return

Returns the sum of the square of individual values in vd minus some reference value.

Examples

No ref value specified

// Calculates the mean-subtracted sum of squares:
double sumSq = ss(dataset);


ref is a constant

// Calculates the sum of squares, after subtracting 4 from each member 
// of 'dataset':
double sumSq = ss(dataset,4);

ref is a dataset

// Calculates the sum of squares, subtracting each corresponding member 
// of 'dataset2' from 'dataset1':
double sumSq = ss(dataset1,dataset2);

ref is a function of i or x

ref is an expression involving x or i, where x is the X-value corresponding to each element in dataset (assumed to be Y-values), and i is the corresponding row number for each element in dataset.

double AA = 1;
double BB = 2;

// Calculates the sum of squares, subtracting the line described by 1+2x:
double sumSq = ss(dataset, AA+BB*x);