public void NoNullCollection() { Assert.Throws <ArgumentNullException>(delegate { var stats = new WelfordVariance(null); }); Assert.Throws <ArgumentNullException>(delegate { var stats = new WelfordVariance(); stats.AddRange(null); }); }
public void Example6() { var stats = new WelfordVariance(); stats.AddRange(new double[] { 2, 4, 4, 4, 5, 5, 7, 9 }); Assert.Equal(8, stats.Count); Assert.Equal(5, stats.Mean, 15); Assert.Equal(4, stats.Variance, 15); Assert.Equal(4.571428571428571, stats.SampleVariance, 15); Assert.Equal(2, stats.StandardDeviation, 15); Assert.Equal(2.138089935299395, stats.SampleStandardDeviation, 15); Assert.Equal(0.427617987059879, stats.RelativeStandardDeviation, 15); }
public void Example10() { var stats = new WelfordVariance(); stats.AddRange(new double[] { -1, 0, 1 }); Assert.Equal(3, stats.Count); Assert.Equal(0, stats.Mean, 15); Assert.Equal(0.666666666666667, stats.Variance, 15); Assert.Equal(1, stats.SampleVariance, 15); Assert.Equal(0.816496580927726, stats.StandardDeviation, 15); Assert.Equal(1, stats.SampleStandardDeviation, 15); Assert.Equal(double.PositiveInfinity, stats.RelativeStandardDeviation, 15); }
public void Example9() { var stats = new WelfordVariance(); stats.AddRange(new double[] { -5, -3, -1, 1, 3 }); Assert.Equal(5, stats.Count); Assert.Equal(-1, stats.Mean, 15); Assert.Equal(8, stats.Variance, 15); Assert.Equal(10, stats.SampleVariance, 15); Assert.Equal(2.82842712474619, stats.StandardDeviation, 15); Assert.Equal(3.16227766016838, stats.SampleStandardDeviation, 15); Assert.Equal(3.16227766016838, stats.RelativeStandardDeviation, 15); }
public void Example8() { var stats = new WelfordVariance(); stats.AddRange(new double[] { 51.3, 55.6, 49.9, 52.0 }); Assert.Equal(4, stats.Count); Assert.Equal(52.2, stats.Mean, 15); Assert.Equal(4.425000000000004, stats.Variance, 15); Assert.Equal(5.900000000000006, stats.SampleVariance, 15); Assert.Equal(2.103568396796264, stats.StandardDeviation, 15); Assert.Equal(2.428991560298225, stats.SampleStandardDeviation, 15); Assert.Equal(0.046532405369698, stats.RelativeStandardDeviation, 15); }
public void Example7() { var stats = new WelfordVariance(); stats.AddRange(new double[] { 9, 2, 5, 4, 12, 7, 8, 11, 9, 3, 7, 4, 12, 5, 4, 10, 9, 6, 9, 4 }); Assert.Equal(20, stats.Count); Assert.Equal(7, stats.Mean, 15); Assert.Equal(8.9, stats.Variance, 15); Assert.Equal(9.368421052631579, stats.SampleVariance, 15); Assert.Equal(2.983286778035260, stats.StandardDeviation, 15); Assert.Equal(3.060787652326044, stats.SampleStandardDeviation, 15); Assert.Equal(0.437255378903721, stats.RelativeStandardDeviation, 15); }