public void GaussianRectangleTest(int left, int right, int top, int bottom) { double totalX = 0; double totalY = 0; Point sample; for (int i = 0; i < numSamples; i++) { sample = Probability.GaussianRectangle(left, right, top, bottom); Assert.IsFalse(sample.X < left); Assert.IsFalse(sample.X > right); Assert.IsFalse(sample.Y < top); Assert.IsFalse(sample.Y > bottom); totalX += sample.X; totalY += sample.Y; } double meanX = totalX / numSamples; double meanY = totalY / numSamples; double expectedX = Numerical.Average(left, right); double expectedY = Numerical.Average(top, bottom); double maxHorizontalDispersion = 2.5 * ((right - left) / Math.Sqrt(numSamples)); double maxVerticalDispersion = 2.5 * ((bottom - top) / Math.Sqrt(numSamples)); Assert.AreEqual(expectedX, meanX, maxHorizontalDispersion); Assert.AreEqual(expectedY, meanY, maxVerticalDispersion); }
public void AveragePointsTest(int ax, int ay, int bx, int by, int cx, int cy) { Point a = new Point(ax, ay); Point b = new Point(bx, by); Point average = Numerical.Average(a, b); Point expected = new Point(cx, cy); Assert.IsTrue(expected.Equals(average)); }
public void BoundedGaussianRangeTest(double minValue, double maxValue) { double total = 0; double sample; for (int i = 0; i < numSamples; i++) { sample = Probability.BoundedGaussian(minValue, maxValue); Assert.IsFalse(sample < minValue); Assert.IsFalse(sample > maxValue); total += sample; } double average = total / ((double)numSamples); double maxDeviation = 2.5 * ((maxValue - minValue) / Math.Sqrt(numSamples)); double expectedMean = Numerical.Average(minValue, maxValue); }
public void AverageTest(double a, double b, double mean) { Assert.AreEqual(Numerical.Average(a, b), mean, 0.001); }