private double interpolateEnd(InflationInterpolatedRateComputation computation, PriceIndexValues values) { double weight = computation.getWeight(); double indexValue1 = values.value(computation.getEndObservation()); double indexValue2 = values.value(computation.getEndSecondObservation()); return weight * indexValue1 + (1d - weight) * indexValue2; }
private double interpolateStart(InflationInterpolatedRateComputation computation, PriceIndexValues values) { double weight = computation.getWeight(); double indexValue1 = values.value(computation.getStartObservation()); double indexValue2 = values.value(computation.getStartSecondObservation()); return weight * indexValue1 + (1d - weight) * indexValue2; }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case -1098347926: // startObservation return ((InflationInterpolatedRateComputation) bean).getStartObservation(); case 1287141078: // startSecondObservation return ((InflationInterpolatedRateComputation) bean).getStartSecondObservation(); case 82210897: // endObservation return ((InflationInterpolatedRateComputation) bean).getEndObservation(); case 1209389949: // endSecondObservation return ((InflationInterpolatedRateComputation) bean).getEndSecondObservation(); case -791592328: // weight return ((InflationInterpolatedRateComputation) bean).getWeight(); } return super.propertyGet(bean, propertyName, quiet); }
private PointSensitivityBuilder endSensitivity(InflationInterpolatedRateComputation computation, PriceIndexValues values) { double weight = computation.getWeight(); PointSensitivityBuilder sensi1 = values.valuePointSensitivity(computation.getEndObservation()) .multipliedBy(weight); PointSensitivityBuilder sensi2 = values.valuePointSensitivity(computation.getEndSecondObservation()) .multipliedBy(1d - weight); return sensi1.combinedWith(sensi2); }
private PointSensitivityBuilder startSensitivity(InflationInterpolatedRateComputation computation, PriceIndexValues values) { double weight = computation.getWeight(); PointSensitivityBuilder sensi1 = values.valuePointSensitivity(computation.getStartObservation()) .multipliedBy(weight); PointSensitivityBuilder sensi2 = values.valuePointSensitivity(computation.getStartSecondObservation()) .multipliedBy(1d - weight); return sensi1.combinedWith(sensi2); }
public void test_of() { InflationInterpolatedRateComputation test = InflationInterpolatedRateComputation.of( GB_HICP, START_MONTH_FIRST, END_MONTH_FIRST, WEIGHT); assertEquals(test.getIndex(), GB_HICP); assertEquals(test.getStartObservation().getFixingMonth(), START_MONTH_FIRST); assertEquals(test.getStartSecondObservation().getFixingMonth(), START_MONTH_SECOND); assertEquals(test.getEndObservation().getFixingMonth(), END_MONTH_FIRST); assertEquals(test.getEndSecondObservation().getFixingMonth(), END_MONTH_SECOND); assertEquals(test.getWeight(), WEIGHT, 1.0e-14); }
double w1 = computation.getWeight(); double w2 = 1d - w1; builder.addListEntry(ExplainKey.OBSERVATIONS, child -> child