Exemplo n.º 1
0
        /// <summary>
        /// Adds a stats object with another type of stats object. The result
        /// should be equivalent, up to the effects of numerical imprecision,
        /// as if in addition to all the values this object has seen, it has
        /// also seen the values added to the other object.
        /// </summary>
        /// <param name="s"></param>
        public void Add(SummaryStatisticsBase s)
        {
            double delta = s.Mean - Mean;
            double na    = Count;
            double nb    = s.Count;
            double nx    = na + nb;

            if (nb == 0.0)
            {
                return; // No-op.
            }
            M2            += s.M2 + delta * delta * na * nb / nx;
            Count         += s.Count;
            Mean          += delta * nb / nx;
            RawCount      += s.RawCount;
            NonzeroCount  += s.NonzeroCount;
            NonzeroWeight += s.NonzeroWeight;

            if (Max < s.Max)
            {
                Max = s.Max;
            }
            if (Min > s.Min)
            {
                Min = s.Min;
            }
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            SummaryStatisticsBase s = obj as SummaryStatisticsBase;

            if (s == null)
            {
                return(false);
            }
            return(s.RawCount == RawCount && s.Count == Count &&
                   s.Mean == Mean && s.M2 == M2 && s.Min == Min &&
                   s.Max == Max && s.NonzeroCount == NonzeroCount);
        }