Beispiel #1
0
 public void Add(int index, double v)
 {
     if (index < _stat.Length)
     {
         RunningStatValue.Add(ref _stat[index], ref _n[index], v);
     }
 }
Beispiel #2
0
        public static void Add(ref RunningStatValue stat, ref double n, double x)
        {
            var np1 = n + 1;

            var oldM = stat._oldM;
            var oldS = stat._oldS;
            var newM = oldM + (x - oldM) / np1;
            var newS = oldS + (x - oldM) * (x - newM);

            stat._oldM = newM;
            stat._oldS = newS;
            stat._newM = newM;
            stat._newS = newS;

            n = np1;
        }