LearningFactorFunctionFactory { public static LearningFactorFunction quasiSigmoidDecay(final double initValue, final double slope, final long numCall) { if (initValue <= 0 || initValue > 1) { throw new OutOfRangeException(initValue, 0, 1); } return new LearningFactorFunction() { private final QuasiSigmoidDecayFunction decay = new QuasiSigmoidDecayFunction(initValue, slope, 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 testQuasiSigmoidDecayPrecondition0() { LearningFactorFunctionFactory.quasiSigmoidDecay(0d, -1d, 2); }
@Test(expected=OutOfRangeException.class) public void testQuasiSigmoidDecayPrecondition1() { LearningFactorFunctionFactory.quasiSigmoidDecay(1 + 1e-10, -1d, 2); }
@Test(expected=NumberIsTooLargeException.class) public void testQuasiSigmoidDecayPrecondition3() { LearningFactorFunctionFactory.quasiSigmoidDecay(1d, 0d, 100); }
@Test(expected=NotStrictlyPositiveException.class) public void testQuasiSigmoidDecayPrecondition4() { LearningFactorFunctionFactory.quasiSigmoidDecay(1d, -1d, 0); }
@Test public void testQuasiSigmoidDecayTrivial() { final int n = 65; final double init = 0.5; final double slope = -1e-1; final LearningFactorFunction f = LearningFactorFunctionFactory.quasiSigmoidDecay(init, slope, n); Assert.assertEquals(init, f.value(0), 0d); Assert.assertEquals(slope, f.value(n) - f.value(n - 1), 1e-2); Assert.assertEquals(0, f.value(Long.MAX_VALUE), 0d); }