LearningFactorFunctionFactory { public static LearningFactorFunction exponentialDecay(final double initValue, final double valueAtNumCall, final long numCall) { if (initValue <= 0 || initValue > 1) { throw new OutOfRangeException(initValue, 0, 1); } return new LearningFactorFunction() { private final ExponentialDecayFunction decay = new ExponentialDecayFunction(initValue, valueAtNumCall, numCall); public double value(long n) { return decay.value(n); } }; } private  LearningFactorFunctionFactory(); static LearningFactorFunction exponentialDecay(final double initValue,
                                                          final double valueAtNumCall,
                                                          final long numCall); static LearningFactorFunction quasiSigmoidDecay(final double initValue,
                                                           final double slope,
                                                           final long numCall);  }
@Test(expected=OutOfRangeException.class) public void testExponentialDecayPrecondition0() { LearningFactorFunctionFactory.exponentialDecay(0d, 0d, 2); }
@Test(expected=OutOfRangeException.class) public void testExponentialDecayPrecondition1() { LearningFactorFunctionFactory.exponentialDecay(1 + 1e-10, 0d, 2); }
@Test(expected=NotStrictlyPositiveException.class) public void testExponentialDecayPrecondition2() { LearningFactorFunctionFactory.exponentialDecay(1d, 0d, 2); }
@Test(expected=NumberIsTooLargeException.class) public void testExponentialDecayPrecondition3() { LearningFactorFunctionFactory.exponentialDecay(1d, 1d, 100); }
@Test(expected=NotStrictlyPositiveException.class) public void testExponentialDecayPrecondition4() { LearningFactorFunctionFactory.exponentialDecay(1d, 0.2, 0); }
@Test public void testExponentialDecayTrivial() { final int n = 65; final double init = 0.5; final double valueAtN = 0.1; final LearningFactorFunction f = LearningFactorFunctionFactory.exponentialDecay(init, valueAtN, n); Assert.assertEquals(init, f.value(0), 0d); Assert.assertEquals(valueAtN, f.value(n), 0d); Assert.assertEquals(0, f.value(Long.MAX_VALUE), 0d); }