@Override public double yValue(double x) { int i = seasonalityIndex(x); double adjustment = seasonality.get(i); return adjustmentType.applyShift(underlying.yValue(x), adjustment); }
@Override public UnitParameterSensitivity yValueParameterSensitivity(double x) { int i = seasonalityIndex(x); double adjustment = seasonality.get(i); double derivativeFactor = 0d; if (adjustmentType.equals(ShiftType.ABSOLUTE)) { derivativeFactor = 1d; } else if (adjustmentType.equals(ShiftType.SCALED)) { derivativeFactor = adjustment; } else { throw new IllegalArgumentException("ShiftType " + adjustmentType + " is not supported for sensitivities"); } // remove the first point from the underlying sensitivity UnitParameterSensitivity u = underlying.yValueParameterSensitivity(x); UnitParameterSensitivity u2 = UnitParameterSensitivity.of( u.getMarketDataName(), u.getParameterMetadata().subList(1, u.getParameterMetadata().size()), u.getSensitivity().subArray(1)); return u2.multipliedBy(derivativeFactor); }
@ImmutableConstructor private InflationNodalCurve( NodalCurve curve, DoubleArray seasonality, ShiftType adjustmentType) { this.underlying = curve; this.seasonality = seasonality; this.xFixing = curve.getXValues().get(0); this.yFixing = curve.getYValues().get(0); int i = seasonalityIndex(xFixing); ArgChecker.isTrue( adjustmentType.applyShift(yFixing, seasonality.get(i)) - yFixing < 1.0E-10, "Fixing value should be unadjusted"); this.adjustmentType = adjustmentType; }