public void TwoValues() { var stats = new WelfordVariance(); stats.Add(1); stats.Add(2); Assert.Equal(2, stats.Count); Assert.Equal(1.5, stats.Mean, 15); Assert.Equal(0.25, stats.Variance, 15); Assert.Equal(0.5, stats.SampleVariance, 15); Assert.Equal(0.5, stats.StandardDeviation, 15); Assert.Equal(0.707106781186548, stats.SampleStandardDeviation, 15); Assert.Equal(0.471404520791032, stats.RelativeStandardDeviation, 15); }
public void NoInfinity() { var stats = new WelfordVariance(); Assert.Throws <ArgumentOutOfRangeException>(delegate { stats.Add(double.NegativeInfinity); }); Assert.Throws <ArgumentOutOfRangeException>(delegate { stats.Add(double.PositiveInfinity); }); Assert.Throws <ArgumentOutOfRangeException>(delegate { stats.Add(double.NaN); }); }
public void Example1() { var stats = new WelfordVariance(); stats.Add(4); stats.Add(7); stats.Add(13); stats.Add(16); Assert.Equal(4, stats.Count); Assert.Equal(10, stats.Mean, 15); Assert.Equal(22.5, stats.Variance, 15); Assert.Equal(30, stats.SampleVariance, 15); Assert.Equal(4.743416490252569, stats.StandardDeviation, 15); Assert.Equal(5.477225575051661, stats.SampleStandardDeviation, 15); Assert.Equal(0.547722557505166, stats.RelativeStandardDeviation, 15); }
public void Example4() { var stats = new WelfordVariance(); stats.Add(6); stats.Add(2); stats.Add(3); stats.Add(1); Assert.Equal(4, stats.Count); Assert.Equal(3, stats.Mean, 15); Assert.Equal(3.5, stats.Variance, 15); Assert.Equal(4.666666666666667, stats.SampleVariance, 15); Assert.Equal(1.870828693386971, stats.StandardDeviation, 15); Assert.Equal(2.160246899469287, stats.SampleStandardDeviation, 15); Assert.Equal(0.720082299823096, stats.RelativeStandardDeviation, 15); }
public void OneValue() { var stats = new WelfordVariance(); stats.Add(1); Assert.Equal(1, stats.Count); Assert.Equal(double.NaN, stats.Mean); Assert.Equal(double.NaN, stats.Variance); Assert.Equal(double.NaN, stats.SampleVariance); Assert.Equal(double.NaN, stats.StandardDeviation); Assert.Equal(double.NaN, stats.SampleStandardDeviation); Assert.Equal(double.NaN, stats.RelativeStandardDeviation); }