Esempio n. 1
0
 public bool SameState(DoubleMomentStatistics other)
 {
     return(Min.CompareTo(other.Min) == 0 &&
            Max.CompareTo(other.Max) == 0 &&
            _sum.SameState(other._sum) &&
            base.SameState(other));
 }
Esempio n. 2
0
        public static DoubleMomentStatistics ToDoubleMomentStatistics <T>(
            this IEnumerable <T> values, Func <T, double> mapper)
        {
            Require.NonNull(mapper);
            var statistics = new DoubleMomentStatistics();

            foreach (var v in values)
            {
                statistics.Accept(mapper(v));
            }
            return(statistics);
        }
        public void SameState()
        {
            var dms1 = new DoubleMomentStatistics();
            var dms2 = new DoubleMomentStatistics();

            var random = new Random();

            for (var i = 0; i < 100; ++i)
            {
                var value = random.NextDouble();
                dms1.Accept(value);
                dms2.Accept(value);

                Assert.True(dms1.SameState(dms2));
                Assert.True(dms2.SameState(dms1));
                Assert.True(dms1.SameState(dms1));
                Assert.True(dms2.SameState(dms2));
            }
        }