LogNormalVolatilityEstimateConfidenceIntervalCalculator { public ConfidenceInterval getConfidenceInterval(final double volatility, final double confidenceLevel, final int n) { _chiSquare = new ChiSquareDistribution(n - 1); final double alpha = 1 - confidenceLevel; final double lower = volatility * Math.sqrt((n - 1) / _chiSquare.getInverseCDF(1 - alpha / 2)); final double upper = volatility * Math.sqrt((n - 1) / _chiSquare.getInverseCDF(alpha / 2)); return new ConfidenceInterval(volatility, lower, upper, confidenceLevel); }  ConfidenceInterval getConfidenceInterval(final double volatility, final double confidenceLevel, final int n);  }
@Test public void test() { final ConfidenceInterval intervals = CALCULATOR.getConfidenceInterval(0.2743, 0.95, 20); assertEquals(intervals.getLowerInterval(), 0.2086, EPS); assertEquals(intervals.getUpperInterval(), 0.4006, EPS); }