protected void assertGradient(ParameterLimitsTransform transform, double modelParam) { double eps = 1e-5; double g = transform.transformGradient(modelParam); double fdg; try { double down = transform.transform(modelParam - eps); double up = transform.transform(modelParam + eps); fdg = (up - down) / 2 / eps; } catch (IllegalArgumentException e) { double fp = transform.transform(modelParam); try { double up = transform.transform(modelParam + eps); fdg = (up - fp) / eps; } catch (IllegalArgumentException e2) { double down = transform.transform(modelParam - eps); fdg = (fp - down) / eps; } } assertEquals(g, fdg, 1e-6); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testOutOfRange4() { RANGE_LIMITS.transformGradient(1.01); }
protected void assertGradientRoundTrip(ParameterLimitsTransform transform, double modelParam) { double g = transform.transformGradient(modelParam); double fp = transform.transform(modelParam); double gInv = transform.inverseTransformGradient(fp); assertEquals(g, 1.0 / gInv, 1e-8); }