Navigation: Templates > Guide to all Templates > Additional Libraries and Templates > Statistics Library >====== SS (sum of squares) ====== | |
SS(dataset [,meanofset])
SS | Returns the sum of the squared differences between each data set value and the data set's mean. |
dataset | The label of a QUEUE with its first component field defined as a REAL. |
meanofset | A numeric constant or variable representing the average of the data set's values (optional). |
SS computes the sum of the squared differences between each data set value and the data set's mean. The function operates on the numeric set defined by all the entries in the first component of the designated QUEUE (dataset). The computation is a significant factor in several statistical formulas.
The optional parameter helps to optimize the function. If not provided, the mean value is computed internally by the function.
The passed data set does not have to be sorted. The function copies the passed set. The passed data set is unchanged.
Return DataType: REAL
Example:
StatSetX QUEUE,PRE()
X REAL
END
SumOFSquaresX REAL
CODE
FREE(StatSetX) !free the QUEUE
CLEAR(STADAT:RECORD) !clear the record buffer
STADAT:Id = STA:Id !prime the record buffer
STADAT:ItemNumber = 1
SET(STADAT:KeyIdItemNumber,STADAT:KeyIdItemNumber !position file pointer
LOOP !load the QUEUE
NEXT(StatisticsData) !read next record
IF ERRORCODE() OR STADAT:Id NOT = STA:Id
BREAK
ELSE
StatSetX:X = STADAT:X !load the QUEUE buffer
ADD(StatSetX) !add to the QUEUE
END
END
SumOFSquaresX = SS(StatSetX) !call SS