/**
* Tests the Monte Carlo (which required a local volatility surface (strike)) against a static replication (which requires a pure implied volatility surface)
* @param dividends
*/
private void testNumericsForFlatPureVol(final AffineDividends dividends) {
final EquityDividendsCurvesBundle divCurves = new EquityDividendsCurvesBundle(SPOT, DISCOUNT_CURVE, dividends);
final LocalVolatilitySurfaceStrike localVol = VolatilitySurfaceConverter.convertLocalVolSurface(PURE_LOCAL_VOL_FLAT, divCurves);
//get the analytic values of the expected variance if there are no cash dividends
boolean canPriceAnalytic = true;
for (int i = 0; i < dividends.getNumberOfDividends(); i++) {
if (dividends.getAlpha(i) > 0.0) {
canPriceAnalytic = false;
break;
}
}
double anVar1 = 0;
double anVar2 = 0;
if (canPriceAnalytic) {
int index = 0;
double anCorr = 0;
final int n = dividends.getNumberOfDividends();
while (n > 0 && index < n && dividends.getTau(index) < EXPIRY) {
anCorr += FunctionUtils.square(Math.log(1 - dividends.getBeta(index)));
index++;
}
anVar1 = PURE_VOL * PURE_VOL;
anVar2 = anVar1 + anCorr / EXPIRY;
if (PRINT) {
System.out.format("Analytic: RV1 = %1$.8f RV2 = %2$.8f%n", anVar1, anVar2);
}
}
final double fT = divCurves.getF(EXPIRY);
//run Monte Carlo (simulating the actual stock process)
double[] res = MC_CALCULATOR.solve(SPOT, DISCOUNT_CURVE, dividends, EXPIRY, localVol, N_SIMS);
final double mcST = res[0]; //The expected stock price at expiry
final double mcSDST = Math.sqrt(res[3]); //The Standard Deviation of the expected stock price at expiry