BlackScholesGeometricBrownianMotionProcess extends StochasticProcess<T, U> { @Override public Function1D<Double, Double> getPathGeneratingFunction(final T t, final U u, final int steps) { Validate.notNull(t); Validate.notNull(u); if (steps < 1) { throw new IllegalArgumentException("Number of steps must be greater than zero"); } final double k = t.getStrike(); final double m = t.getTimeToExpiry(u.getDate()); final double sigma = u.getVolatility(m, k); final double b = u.getCostOfCarry(); final double dt = m / steps; final double sigmaSq = sigma * sigma; final double nu = dt * (b - 0.5 * sigmaSq); final double sigmaDt = sigma * Math.sqrt(dt); return new Function1D<Double, Double>() { @Override public Double evaluate(final Double e) { return nu + sigmaDt * e; } }; }  @Override Function1D<Double, Double> getPathGeneratingFunction(final T t, final U u, final int steps); @Override Double getInitialValue(final T t, final U u); @Override Double getFinalValue(final Double x); @Override Function2D<Double, Double> getPathAccumulationFunction();  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullDefinition() { PROCESS.getPathGeneratingFunction(null, DATA, 1000); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { PROCESS.getPathGeneratingFunction(CALL, null, 1000); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testInsufficientPaths() { PROCESS.getPathGeneratingFunction(CALL, DATA, -1); }