//============================================================================== // Function for calculation of mean and standard deviation: // input: // nPoints - number of points for processing // pfVext - array with data // output: // pfMean - pointer to mean value // pfStdDev - pointer to standard deviation //============================================================================== #include int CalcMeanStdDev(int nPoints, double* pfVect, double* pfMean,double* pfStdDev) { int i; double fSum=0.; double fSum2=0.; double fPoints = (double) nPoints; if(nPoints < 2) return 1; // not enough data ! for(i=0; i //============================================================================== // TEST: //============================================================================== int main(int nArgs, char** ppArgs) { int n = 9; double dat[9] = {1., 2., 3., 4., 5., 6., 7., 8., 9.}; double fMean, fStdDev; CalcMeanStdDev(n, dat, &fMean, &fStdDev); printf("mean=%f stddev=%f\n", fMean, fStdDev); return 0; }