CalcExtSD.c



void CalcExtSD(REAL val, int action, REAL *Sx, REAL *SxSq, int *NValues, REAL *mean, REAL *SD)

Description

Calculate the mean and standard deviation from a set of numbers. The routine is called with each value to be sampled and the action required is specified:

Inputs

val int The value to be sampled
action short 0: Sample the value 1: Calculate & return mean and SD 2: Clear the sample lists

Outputs

mean *REAL The returned mean
SD *REAL The returned standard deviation

Input/Output

Sx *REAL Sum of values
SxSq *REAL Sum of values squared
NValues *int Number of values

The output values are only set when action==1

This is the same as CalcSD except that the Sx, SxSq and NValues variables are kept outside the function instead of being static within the function

Created: 13.10.93 Last Modified: 22.06.94