/*************************************************************************\ * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * This file is distributed subject to a Software License Agreement found * in the file LICENSE that is included with this distribution. \*************************************************************************/ /* $Log: moments.c,v $ Revision 1.6 2002/08/14 16:18:59 soliday Added Open License Revision 1.5 2001/11/09 19:33:00 borland Fixed error in equations in accumulateWeightedMoments(). Revision 1.4 1999/05/28 14:56:51 soliday Removed compiler warnings under Linux. Revision 1.3 1995/09/06 14:13:34 saunders First test release of SDDS1.5 */ /* file: moments.c * contents: standardDeviation(), computeMoments(), computeWeightedMoments(), * accumulateMoments(), accumulateWeightedMoments(), computeCorrelations(), * arithmeticAverage(), rmsValue(), meanAbsoluteDeviation(), * weightedAverage(), weightedRMS(), weightedStDev(), weightedMAD() * Michael Borland, 1992, 1995 */ #include "mdb.h" double standardDeviation(double *x, long n) { long i; double sum, sumSqr, value, mean; if (n<1) return(0.0); for (i=sum=0; i