public void ClockTest() { double[] hours = { 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23, 1, 23 }; double mean = Circular.Mean(hours, 24); double stdDev = Circular.StandardDeviation(hours, 24); double var = Circular.Variance(hours, 24); double med = Circular.Median(hours, 24); DoubleRange quartiles; double median = Circular.Quartiles(hours, 24, out quartiles); double d = Circular.Distance(1, 23, 24); Assert.AreEqual(0, mean); Assert.AreEqual(1.0058013608769885, stdDev, 1e-11); Assert.AreEqual(0.4971507281317768, var, 1e-11); Assert.AreEqual(0, med); Assert.AreEqual(0, median); Assert.AreEqual(23, quartiles.Min, 1e-13); Assert.AreEqual(1, quartiles.Max, 1e-13); Assert.AreEqual(2, d, 1e-15); }
public void ClockTest2() { double[] hours = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }; double mean = Circular.Mean(hours, 24); double stdDev = Circular.StandardDeviation(hours, 24); double var = Circular.Variance(hours, 24); double med = Circular.Median(hours, 24); DoubleRange quartiles; double median = Circular.Quartiles(hours, 24, out quartiles); double d1 = Circular.Distance(23, 0, 24); double d2 = Circular.Distance(0, 23, 24); Assert.AreEqual(6, mean, 1e-15); Assert.AreEqual(3.9598525326427247, stdDev, 1e-14); Assert.AreEqual(6.0653308429985406, var, 1e-14); Assert.AreEqual(6, med); Assert.AreEqual(6, median); Assert.AreEqual(2.5, quartiles.Min); Assert.AreEqual(9.5, quartiles.Max); Assert.AreEqual(-1, d1, 1e-15); Assert.AreEqual(+1, d2, 1e-15); }
public void DistanceTest() { double x = 0.15; double y = -1.22; double expected = 1.37; double actual = Circular.Distance(x, y); Assert.AreEqual(expected, actual, 1e-15); }