コード例 #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));
 }
コード例 #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);
        }
コード例 #3
0
        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));
            }
        }