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
示例#1
0
        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();
            }
        }
示例#2
0
        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();
        }