IncompleteBetaFunction extends Function1D<Double, Double> { @Override public Double evaluate(final Double x) { Validate.isTrue(x >= 0 && x <= 1, "x must be in the range 0 to 1"); try { return Beta.regularizedBeta(x, _a, _b, _eps, _maxIter); } catch (final org.apache.commons.math.MathException e) { throw new MathException(e); } } IncompleteBetaFunction(final double a, final double b);  IncompleteBetaFunction(final double a, final double b, final double eps, final int maxIter); @Override Double evaluate(final Double x);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testLow() { BETA.evaluate(-0.3); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testHigh() { BETA.evaluate(1.5); }
@Test public void test() { final double a = RANDOM.nextDouble(); final double b = RANDOM.nextDouble(); final double x = RANDOM.nextDouble(); final Function1D<Double, Double> f1 = new IncompleteBetaFunction(a, b); final Function1D<Double, Double> f2 = new IncompleteBetaFunction(b, a); assertEquals(f1.evaluate(0.), 0, EPS); assertEquals(f1.evaluate(1.), 1, EPS); assertEquals(f1.evaluate(x), 1 - f2.evaluate(1 - x), EPS); }