This class keeps track of the mean and variance of a stream of numbers. It keeps "running" tallies of these quantities, so its memory consumption does not increase as more values are added. This implementation is a c# port of the c++ code presented at http://www.johndcook.com/standard_deviation.html
        public void Add(TOF t)
        {
            if (!initialised)
            {
                // the first TOF to be added defines the parameters
                gateStartTime = t.GateStartTime;
                clockPeriod   = t.ClockPeriod;
                calibration   = t.Calibration;
                stats         = new RunningStatistics[t.Length];
                for (int i = 0; i < Length; i++)
                {
                    stats[i] = new RunningStatistics();
                }
                initialised = true;
            }

            // add the TOF data - very minimal error checking: just check the lengths
            if (t.Length == Length)
            {
                for (int i = 0; i < Length; i++)
                {
                    stats[i].Push(t.Data[i]);
                }
            }
            else
            {
                throw new TOFAccumulatorException();
            }
        }
        public void Add(TOF t)
        {
            if (!initialised)
            {
                // the first TOF to be added defines the parameters
                gateStartTime = t.GateStartTime;
                clockPeriod = t.ClockPeriod;
                calibration = t.Calibration;
                stats = new RunningStatistics[t.Length];
                for (int i = 0; i < Length; i++) stats[i] = new RunningStatistics();
                initialised = true;
            }

            // add the TOF data - very minimal error checking: just check the lengths
            if (t.Length == Length) for (int i = 0; i < Length; i++) stats[i].Push(t.Data[i]);
            else throw new TOFAccumulatorException();
        }