StudentTLinearVaRCalculator implements VaRCalculator<StudentTVaRParameters, T> { @SuppressWarnings("unchecked") @Override public VaRCalculationResult evaluate(final StudentTVaRParameters parameters, final T... data) { ArgumentChecker.notNull(parameters, "parameters"); ArgumentChecker.notNull(data, "data"); final Double value = parameters.getMult() * _stdCalculator.evaluate(data) - parameters.getScale() * _meanCalculator.evaluate(data); return new VaRCalculationResult(value, null); } StudentTLinearVaRCalculator(final Function<T, Double> meanCalculator, final Function<T, Double> stdCalculator); @SuppressWarnings("unchecked") @Override VaRCalculationResult evaluate(final StudentTVaRParameters parameters, final T... data); Function<T, Double> getMeanCalculator(); Function<T, Double> getStandardDeviationCalculator(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullParameters() { STUDENT_T_VAR.evaluate(null, 0.); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testNullData() { STUDENT_T_VAR.evaluate(STUDENT_T_PARAMETERS, (Double[]) null); }
@Test public void test() { final Double data = 0.; assertEquals(NORMAL_VAR.evaluate(NORMAL_PARAMETERS, data).getVaRValue(), STUDENT_T_VAR.evaluate(HIGH_DOF_PARAMETERS, data).getVaRValue(), 1e-6); assertTrue(STUDENT_T_VAR.evaluate(STUDENT_T_PARAMETERS, data).getVaRValue() > NORMAL_VAR.evaluate(NORMAL_PARAMETERS, data).getVaRValue()); }