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 testOutOfRange2() { RANGE_LIMITS.transform(1.01); }
// reverse protected void assertReverseRoundTrip(ParameterLimitsTransform transform, double fitParam) { double mp = transform.inverseTransform(fitParam); double fp = transform.transform(mp); assertEquals(fitParam, fp, 1e-8); }
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); }
protected void assertRoundTrip(ParameterLimitsTransform transform, double modelParam) { double fp = transform.transform(modelParam); double mp = transform.inverseTransform(fp); assertEquals(modelParam, mp, 1e-8); }