@Override public boolean isLocallyMonotone() throws java.lang.Exception { int iNumSegment = _aLSRM.length; for (int i = 0; i < iNumSegment; ++i) { org.drip.spline.segment.Monotonocity mono = null; try { mono = _aLSRM[i].monotoneType(); } catch (java.lang.Exception e) { e.printStackTrace(); } if (null == mono || org.drip.spline.segment.Monotonocity.MONOTONIC != mono.type()) return false; } return true; }
@Override public boolean isCoMonotone(final double[] adblMeasuredResponse) throws java.lang.Exception { int iNumSegment = _aLSRM.length; int[] aiMonotoneType = new int[iNumSegment]; int[] aiNodeMiniMax = new int[iNumSegment + 1]; if (null == adblMeasuredResponse || adblMeasuredResponse.length != iNumSegment + 1) throw new java.lang.Exception( "CalibratableMultiSegmentSequence::isCoMonotone => Data input inconsistent with the segment"); for (int i = 0; i < iNumSegment + 1; ++i) { if (0 == i || iNumSegment == i) aiNodeMiniMax[i] = MONOTONE_PREDICTOR_ORDINATE_NODE; else { if (adblMeasuredResponse[i - 1] < adblMeasuredResponse[i] && adblMeasuredResponse[i + 1] < adblMeasuredResponse[i]) aiNodeMiniMax[i] = MAXIMA_PREDICTOR_ORDINATE_NODE; else if (adblMeasuredResponse[i - 1] > adblMeasuredResponse[i] && adblMeasuredResponse[i + 1] > adblMeasuredResponse[i]) aiNodeMiniMax[i] = MINIMA_PREDICTOR_ORDINATE_NODE; else aiNodeMiniMax[i] = MONOTONE_PREDICTOR_ORDINATE_NODE; } if (i < iNumSegment) { org.drip.spline.segment.Monotonocity mono = _aLSRM[i].monotoneType(); if (null != mono) aiMonotoneType[i] = mono.type(); } } for (int i = 1; i < iNumSegment; ++i) { if (MAXIMA_PREDICTOR_ORDINATE_NODE == aiNodeMiniMax[i]) { if (org.drip.spline.segment.Monotonocity.MAXIMA != aiMonotoneType[i] && org.drip.spline.segment.Monotonocity.MAXIMA != aiMonotoneType[i - 1]) return false; } else if (MINIMA_PREDICTOR_ORDINATE_NODE == aiNodeMiniMax[i]) { if (org.drip.spline.segment.Monotonocity.MINIMA != aiMonotoneType[i] && org.drip.spline.segment.Monotonocity.MINIMA != aiMonotoneType[i - 1]) return false; } } return true; }