Package org.drip.spline.stretch
Class CalibratableMultiSegmentSequence
java.lang.Object
org.drip.function.definition.R1ToR1
org.drip.spline.stretch.CalibratableMultiSegmentSequence
- All Implemented Interfaces:
MultiSegmentSequence,SingleSegmentSequence
- Direct Known Subclasses:
CurveStretch
public class CalibratableMultiSegmentSequence extends R1ToR1 implements MultiSegmentSequence
CalibratableMultiSegmentSequence implements the MultiSegmentSequence span that spans multiple
segments. It holds the ordered segment sequence, segment sequence builder, the segment control
parameters, and, if available, the spanning Jacobian. It provides a variety of customization for the
segment construction and state representation control.
| Module | Product Core Module |
| Library | Fixed Income Analytics |
| Project | Basis Splines and Linear Compounders across a Broad Family of Spline Basis Functions |
| Package | Multi-Segment Sequence Spline Stretch |
- Author:
- Lakshmi Krishnamurthy
-
Field Summary
Fields inherited from interface org.drip.spline.stretch.MultiSegmentSequence
CALIBRATE, CALIBRATE_JACOBIAN -
Constructor Summary
Constructors Constructor Description CalibratableMultiSegmentSequence(java.lang.String name, LatentStateResponseModel[] latentStateResponseModelArray, SegmentCustomBuilderControl[] segmentCustomBuilderControlArray)CalibratableMultiSegmentSequence constructor - Construct a sequence of Basis Spline Segments -
Method Summary
Modifier and Type Method Description doublebestFitDPE(StretchBestFitResponse stretchBestFitResponse)Retrieve the Stretch Best Fit DPEdoublecalcLeftEdgeDerivative(int order)Calculate the Derivative of the requested order at the Left Edge of the StretchdoublecalcRightEdgeDerivative(int order)Calculate the Derivative of the requested order at the right Edge of the StretchSegmentPredictorResponseDerivativecalcSPRD(double predictorOrdinate)Calculate the SegmentPredictorResponseDerivative at the specified Predictor OrdinateCalibratableMultiSegmentSequenceclipLeft(java.lang.String name, double predictorOrdinate)Generate a new Stretch by clipping all the Segments to the Left of the specified Predictor Ordinate.CalibratableMultiSegmentSequenceclipRight(java.lang.String name, double predictorOrdinate)Generate a new Stretch by clipping all the Segments to the Right of the specified Predictor Ordinate.intcontainingIndex(double predictorOrdinate, boolean includeLeft, boolean includeRight)Return the Index for the Segment containing specified Predictor OrdinatedoublecurvatureDPE()Retrieve the Span Curvature DPEjava.lang.StringdisplayString()Display the Segmentsdoubleevaluate(double leftSlope)Evaluate for the given variatedoublegetLeftPredictorOrdinateEdge()Return the Left Predictor Ordinate EdgedoublegetRightPredictorOrdinateEdge()Return the Right Predictor Ordinate Edgebooleanin(double predictorOrdinate)Check if the Predictor Ordinate is in the Stretch Rangedoubleintegrate(double begin, double end)Integrate over the given rangebooleanisCoMonotone(double[] measuredResponseArray)Verify whether the Stretch mini-max Behavior matches the MeasurementbooleanisKnot(double predictorOrdinate)Is the given Predictor Ordinate a Knot LocationbooleanisLocallyMonotone()Indicate if all the comprising Segments are MonotoneWengertJacobianjackDResponseDCalibrationInput(double predictorOrdinate, int order)Calculate the Response Derivative to the Calibration Inputs at the specified OrdinateWengertJacobianjackDResponseDManifestMeasure(java.lang.String manifestMeasure, double predictorOrdinate, int order)Calculate the Response Derivative to the Manifest Measure at the specified OrdinatedoublelengthDPE()Retrieve the Span Length DPEMonotonocitymonotoneType(double predictorOrdinate)Identify the Monotone Type for the Segment underlying the given Predictor OrdinateMergeSubStretchManagermsm()Retrieve the Merge Stretch Manager if it exists.java.lang.Stringname()Retrieve the Stretch NamebooleanresetNode(int predictorOrdinateIndex, double responseReset)Reset the Predictor Ordinate Node Index with the given ResponsebooleanresetNode(int predictorOrdinateIndex, SegmentResponseValueConstraint resetSegmentResponseValueConstraint)Reset the Predictor Ordinate Node Index with the given Segment ConstraintdoubleresponseValue(double predictorOrdinate)Calculate the Response Value at the given Predictor OrdinatedoubleresponseValueDerivative(double predictorOrdinate, int iOrder)Calculate the Response Value Derivative at the given Predictor Ordinate for the specified orderSegmentCustomBuilderControl[]segmentBuilderControl()Retrieve the Segment Builder ParametersLatentStateResponseModel[]segments()Retrieve the Stretch SegmentsbooleansetLeftNode(double stretchLeftResponse, double stretchLeftResponseSlope, double stretchRightResponse, StretchBestFitResponse stretchBestFitResponse)Set the Slope at the left Edge of the Stretchbooleansetup(double leftStretchResponseValue, double[] segmentRightResponseValueArray, StretchBestFitResponse stretchBestFitResponse, BoundarySettings boundarySettings, int calibrationDetail)Set up (i.e., calibrate) the individual Segments in the Stretch to the Response Values corresponding to each Segment Predictor right Ordinate.booleansetup(double leftStretchResponseValue, SegmentResponseValueConstraint[] segmentResponseValueConstraintArray, StretchBestFitResponse stretchBestFitResponse, BoundarySettings bBoundarySettings, int calibrationDetail)Set up (i.e., calibrate) the individual Segments in the Stretch to the Stretch Left Edge Response and the Target Constraints.booleansetup(SegmentResponseValueConstraint leadingSegmentResponseValueConstraint, SegmentResponseValueConstraint[] segmentResponseValueConstraintArray, StretchBestFitResponse stretchBestFitResponse, BoundarySettings boundarySettings, int calibrationDetail)Set up (i.e., calibrate) the individual Segments in the Stretch to the Stretch Left Edge and the Target Constraints.booleansetup(SegmentSequenceBuilder segmentSequenceBuilder, int calibrationDetail)Set up (i.e., calibrate) the individual Segments in the Stretch to the Stretch Edge, the Target Constraints, and the custom segment sequence builder.booleansetupHermite(SegmentPredictorResponseDerivative[] leftSegmentPredictorResponseDerivativeArray, SegmentPredictorResponseDerivative[] rightSegmentPredictorResponseDerivativeArray, SegmentResponseValueConstraint[][] segmentResponseValueConstraintGrid, StretchBestFitResponse sbfr, int iSetupMode)Set up (i.e., calibrate) the individual Segment in the Stretch to the Target Segment Edge Values and Constraints.R1ToR1toAU()Convert the Segment Sequence into an AbstractUnivariate InstanceMethods inherited from class org.drip.function.definition.R1ToR1
antiDerivative, conditionNumber, derivative, differential, differential, maxima, maxima, minima, minima, poleResidueMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CalibratableMultiSegmentSequence
public CalibratableMultiSegmentSequence(java.lang.String name, LatentStateResponseModel[] latentStateResponseModelArray, SegmentCustomBuilderControl[] segmentCustomBuilderControlArray) throws java.lang.ExceptionCalibratableMultiSegmentSequence constructor - Construct a sequence of Basis Spline Segments- Parameters:
name- Name of the StretchlatentStateResponseModelArray- Array of SegmentssegmentCustomBuilderControlArray- Array of Segment Builder Parameters- Throws:
java.lang.Exception- Thrown if the inputs are invalid
-
-
Method Details
-
name
public java.lang.String name()Description copied from interface:MultiSegmentSequenceRetrieve the Stretch Name- Specified by:
namein interfaceMultiSegmentSequence- Returns:
- The Stretch Name
-
segments
Description copied from interface:MultiSegmentSequenceRetrieve the Stretch Segments- Specified by:
segmentsin interfaceMultiSegmentSequence- Returns:
- The Stretch Segments
-
segmentBuilderControl
Description copied from interface:MultiSegmentSequenceRetrieve the Segment Builder Parameters- Specified by:
segmentBuilderControlin interfaceMultiSegmentSequence- Returns:
- The Segment Builder Parameters
-
setup
Description copied from interface:MultiSegmentSequenceSet up (i.e., calibrate) the individual Segments in the Stretch to the Stretch Edge, the Target Constraints, and the custom segment sequence builder.- Specified by:
setupin interfaceMultiSegmentSequence- Parameters:
segmentSequenceBuilder- The Segment Sequence Builder InstancecalibrationDetail- The Calibration Detail- Returns:
- TRUE - Set up was successful
-
setup
public boolean setup(SegmentResponseValueConstraint leadingSegmentResponseValueConstraint, SegmentResponseValueConstraint[] segmentResponseValueConstraintArray, StretchBestFitResponse stretchBestFitResponse, BoundarySettings boundarySettings, int calibrationDetail)Description copied from interface:MultiSegmentSequenceSet up (i.e., calibrate) the individual Segments in the Stretch to the Stretch Left Edge and the Target Constraints.- Specified by:
setupin interfaceMultiSegmentSequence- Parameters:
leadingSegmentResponseValueConstraint- Stretch Left-most Segment Response Value ConstraintsegmentResponseValueConstraintArray- Array of Segment Response Value ConstraintsstretchBestFitResponse- Stretch Fitness Weighted ResponseboundarySettings- The Calibration Boundary ConditioncalibrationDetail- The Calibration Detail- Returns:
- TRUE - Set up was successful
-
setup
public boolean setup(double leftStretchResponseValue, SegmentResponseValueConstraint[] segmentResponseValueConstraintArray, StretchBestFitResponse stretchBestFitResponse, BoundarySettings bBoundarySettings, int calibrationDetail)Description copied from interface:MultiSegmentSequenceSet up (i.e., calibrate) the individual Segments in the Stretch to the Stretch Left Edge Response and the Target Constraints.- Specified by:
setupin interfaceMultiSegmentSequence- Parameters:
leftStretchResponseValue- Stretch Left-most Response ValuesegmentResponseValueConstraintArray- Array of Segment Response Value ConstraintsstretchBestFitResponse- Stretch Best Fit Weighted Response ValuesbBoundarySettings- The Calibration Boundary ConditioncalibrationDetail- The Calibration Detail- Returns:
- TRUE - Set up was successful
-
setup
public boolean setup(double leftStretchResponseValue, double[] segmentRightResponseValueArray, StretchBestFitResponse stretchBestFitResponse, BoundarySettings boundarySettings, int calibrationDetail)Description copied from interface:SingleSegmentSequenceSet up (i.e., calibrate) the individual Segments in the Stretch to the Response Values corresponding to each Segment Predictor right Ordinate.- Specified by:
setupin interfaceSingleSegmentSequence- Parameters:
leftStretchResponseValue- Stretch Left-most ResponsesegmentRightResponseValueArray- Array of Segment Right Edge ResponsesstretchBestFitResponse- Stretch Fitness Weighted ResponseboundarySettings- The Calibration Boundary ConditioncalibrationDetail- The Calibration Detail- Returns:
- TRUE - Set up was successful
-
setupHermite
public boolean setupHermite(SegmentPredictorResponseDerivative[] leftSegmentPredictorResponseDerivativeArray, SegmentPredictorResponseDerivative[] rightSegmentPredictorResponseDerivativeArray, SegmentResponseValueConstraint[][] segmentResponseValueConstraintGrid, StretchBestFitResponse sbfr, int iSetupMode)Description copied from interface:MultiSegmentSequenceSet up (i.e., calibrate) the individual Segment in the Stretch to the Target Segment Edge Values and Constraints. This is also called the Hermite setup - where the segment boundaries are entirely locally set.- Specified by:
setupHermitein interfaceMultiSegmentSequence- Parameters:
leftSegmentPredictorResponseDerivativeArray- Array of Left Segment Edge ValuesrightSegmentPredictorResponseDerivativeArray- Array of Right Segment Edge ValuessegmentResponseValueConstraintGrid- Double Array of Constraints - Outer Index corresponds to Segment Index, and the Inner Index to Constraint Array within each Segmentsbfr- Stretch Fitness Weighted ResponseiSetupMode- Set up Mode (i.e., set up ITEP only, or fully calibrate the Stretch, or calibrate Stretch plus compute Jacobian)- Returns:
- TRUE - Set up was successful
-
evaluate
public double evaluate(double leftSlope) throws java.lang.ExceptionDescription copied from class:R1ToR1Evaluate for the given variate -
integrate
public double integrate(double begin, double end) throws java.lang.ExceptionDescription copied from class:R1ToR1Integrate over the given range -
setLeftNode
public boolean setLeftNode(double stretchLeftResponse, double stretchLeftResponseSlope, double stretchRightResponse, StretchBestFitResponse stretchBestFitResponse)Description copied from interface:MultiSegmentSequenceSet the Slope at the left Edge of the Stretch- Specified by:
setLeftNodein interfaceMultiSegmentSequence- Parameters:
stretchLeftResponse- Response Value at the Left Edge of the StretchstretchLeftResponseSlope- Response Slope Value at the Left Edge of the StretchstretchRightResponse- Response Value at the Right Edge of the StretchstretchBestFitResponse- Stretch Fitness Weighted Response- Returns:
- TRUE - Left slope successfully set
-
responseValue
public double responseValue(double predictorOrdinate) throws java.lang.ExceptionDescription copied from interface:SingleSegmentSequenceCalculate the Response Value at the given Predictor Ordinate- Specified by:
responseValuein interfaceSingleSegmentSequence- Parameters:
predictorOrdinate- Predictor Ordinate- Returns:
- The Response Value
- Throws:
java.lang.Exception- Thrown if the Response Value cannot be calculated
-
responseValueDerivative
public double responseValueDerivative(double predictorOrdinate, int iOrder) throws java.lang.ExceptionDescription copied from interface:SingleSegmentSequenceCalculate the Response Value Derivative at the given Predictor Ordinate for the specified order- Specified by:
responseValueDerivativein interfaceSingleSegmentSequence- Parameters:
predictorOrdinate- Predictor OrdinateiOrder- Order the Derivative- Returns:
- The Response Value
- Throws:
java.lang.Exception- Thrown if the Response Value Derivative cannot be calculated
-
calcSPRD
Description copied from interface:MultiSegmentSequenceCalculate the SegmentPredictorResponseDerivative at the specified Predictor Ordinate- Specified by:
calcSPRDin interfaceMultiSegmentSequence- Parameters:
predictorOrdinate- The Predictor Ordinate- Returns:
- The Computed SegmentPredictorResponseDerivative
-
jackDResponseDCalibrationInput
Description copied from interface:SingleSegmentSequenceCalculate the Response Derivative to the Calibration Inputs at the specified Ordinate- Specified by:
jackDResponseDCalibrationInputin interfaceSingleSegmentSequence- Parameters:
predictorOrdinate- Predictor Ordinateorder- Order of Derivative desired- Returns:
- Jacobian of the Response Derivative to the Calibration Inputs at the Ordinate
-
jackDResponseDManifestMeasure
public WengertJacobian jackDResponseDManifestMeasure(java.lang.String manifestMeasure, double predictorOrdinate, int order)Description copied from interface:SingleSegmentSequenceCalculate the Response Derivative to the Manifest Measure at the specified Ordinate- Specified by:
jackDResponseDManifestMeasurein interfaceSingleSegmentSequence- Parameters:
manifestMeasure- Manifest Measure whose Sensitivity is soughtpredictorOrdinate- Predictor Ordinateorder- Order of Derivative desired- Returns:
- Jacobian of the Response Derivative to the Quote at the Ordinate
-
monotoneType
Description copied from interface:SingleSegmentSequenceIdentify the Monotone Type for the Segment underlying the given Predictor Ordinate- Specified by:
monotoneTypein interfaceSingleSegmentSequence- Parameters:
predictorOrdinate- Predictor Ordinate- Returns:
- Segment Monotone Type
-
isLocallyMonotone
public boolean isLocallyMonotone() throws java.lang.ExceptionDescription copied from interface:SingleSegmentSequenceIndicate if all the comprising Segments are Monotone- Specified by:
isLocallyMonotonein interfaceSingleSegmentSequence- Returns:
- TRUE - Fully locally monotonic
- Throws:
java.lang.Exception- Thrown if the Segment Monotone Type could not be estimated
-
isCoMonotone
public boolean isCoMonotone(double[] measuredResponseArray) throws java.lang.ExceptionDescription copied from interface:SingleSegmentSequenceVerify whether the Stretch mini-max Behavior matches the Measurement- Specified by:
isCoMonotonein interfaceSingleSegmentSequence- Parameters:
measuredResponseArray- The Array of Measured Responses- Returns:
- TRUE - Stretch is co-monotonic with the measured Responses
- Throws:
java.lang.Exception- Thrown if the Segment Monotone Type could not be estimated
-
isKnot
public boolean isKnot(double predictorOrdinate)Description copied from interface:SingleSegmentSequenceIs the given Predictor Ordinate a Knot Location- Specified by:
isKnotin interfaceSingleSegmentSequence- Parameters:
predictorOrdinate- Predictor Ordinate- Returns:
- TRUE - Given Predictor Ordinate corresponds to a Knot
-
calcLeftEdgeDerivative
public double calcLeftEdgeDerivative(int order) throws java.lang.ExceptionDescription copied from interface:MultiSegmentSequenceCalculate the Derivative of the requested order at the Left Edge of the Stretch- Specified by:
calcLeftEdgeDerivativein interfaceMultiSegmentSequence- Parameters:
order- Order of the Derivative- Returns:
- The Derivative of the requested order at the Left Edge of the Stretch
- Throws:
java.lang.Exception- Thrown if the Derivative cannot be calculated
-
calcRightEdgeDerivative
public double calcRightEdgeDerivative(int order) throws java.lang.ExceptionDescription copied from interface:MultiSegmentSequenceCalculate the Derivative of the requested order at the right Edge of the Stretch- Specified by:
calcRightEdgeDerivativein interfaceMultiSegmentSequence- Parameters:
order- Order of the Derivative- Returns:
- The Derivative of the requested order at the right Edge of the Stretch
- Throws:
java.lang.Exception- Thrown if the Derivative cannot be calculated
-
resetNode
public boolean resetNode(int predictorOrdinateIndex, double responseReset)Description copied from interface:SingleSegmentSequenceReset the Predictor Ordinate Node Index with the given Response- Specified by:
resetNodein interfaceSingleSegmentSequence- Parameters:
predictorOrdinateIndex- The Predictor Ordinate Node Index whose Response is to be resetresponseReset- The Response to reset- Returns:
- TRUE - Reset succeeded
-
resetNode
public boolean resetNode(int predictorOrdinateIndex, SegmentResponseValueConstraint resetSegmentResponseValueConstraint)Description copied from interface:SingleSegmentSequenceReset the Predictor Ordinate Node Index with the given Segment Constraint- Specified by:
resetNodein interfaceSingleSegmentSequence- Parameters:
predictorOrdinateIndex- The Predictor Ordinate Node Index whose Response is to be resetresetSegmentResponseValueConstraint- The Segment Constraint- Returns:
- TRUE - Reset succeeded
-
toAU
Description copied from interface:SingleSegmentSequenceConvert the Segment Sequence into an AbstractUnivariate Instance- Specified by:
toAUin interfaceSingleSegmentSequence- Returns:
- The AbstractUnivariate Instance
-
in
public boolean in(double predictorOrdinate) throws java.lang.ExceptionDescription copied from interface:MultiSegmentSequenceCheck if the Predictor Ordinate is in the Stretch Range- Specified by:
inin interfaceMultiSegmentSequence- Parameters:
predictorOrdinate- Predictor Ordinate- Returns:
- TRUE - Predictor Ordinate is in the Range
- Throws:
java.lang.Exception- Thrown if the Inputs are invalid
-
getLeftPredictorOrdinateEdge
public double getLeftPredictorOrdinateEdge()Description copied from interface:SingleSegmentSequenceReturn the Left Predictor Ordinate Edge- Specified by:
getLeftPredictorOrdinateEdgein interfaceSingleSegmentSequence- Returns:
- The Left Predictor Ordinate Edge
-
getRightPredictorOrdinateEdge
public double getRightPredictorOrdinateEdge()Description copied from interface:SingleSegmentSequenceReturn the Right Predictor Ordinate Edge- Specified by:
getRightPredictorOrdinateEdgein interfaceSingleSegmentSequence- Returns:
- The Right Predictor Ordinate Edge
-
containingIndex
public int containingIndex(double predictorOrdinate, boolean includeLeft, boolean includeRight) throws java.lang.ExceptionDescription copied from interface:MultiSegmentSequenceReturn the Index for the Segment containing specified Predictor Ordinate- Specified by:
containingIndexin interfaceMultiSegmentSequence- Parameters:
predictorOrdinate- Predictor OrdinateincludeLeft- TRUE - Less than or equal to the Left Predictor OrdinateincludeRight- TRUE - Less than or equal to the Right Predictor Ordinate- Returns:
- Index for the Segment containing specified Predictor Ordinate
- Throws:
java.lang.Exception- Thrown if the Inputs are invalid
-
clipLeft
Description copied from interface:MultiSegmentSequenceGenerate a new Stretch by clipping all the Segments to the Left of the specified Predictor Ordinate. Smoothness Constraints will be maintained.- Specified by:
clipLeftin interfaceMultiSegmentSequence- Parameters:
name- Name of the Clipped StretchpredictorOrdinate- Predictor Ordinate Left of which the Clipping is to be applied- Returns:
- The Clipped Stretch
-
clipRight
Description copied from interface:MultiSegmentSequenceGenerate a new Stretch by clipping all the Segments to the Right of the specified Predictor Ordinate. Smoothness Constraints will be maintained.- Specified by:
clipRightin interfaceMultiSegmentSequence- Parameters:
name- Name of the Clipped StretchpredictorOrdinate- Predictor Ordinate Right of which the Clipping is to be applied- Returns:
- The Clipped Stretch
-
curvatureDPE
public double curvatureDPE() throws java.lang.ExceptionDescription copied from interface:MultiSegmentSequenceRetrieve the Span Curvature DPE- Specified by:
curvatureDPEin interfaceMultiSegmentSequence- Returns:
- The Span Curvature DPE
- Throws:
java.lang.Exception- Thrown if the Span Curvature DPE cannot be computed
-
lengthDPE
public double lengthDPE() throws java.lang.ExceptionDescription copied from interface:MultiSegmentSequenceRetrieve the Span Length DPE- Specified by:
lengthDPEin interfaceMultiSegmentSequence- Returns:
- The Span Length DPE
- Throws:
java.lang.Exception- Thrown if the Span Length DPE cannot be computed
-
bestFitDPE
Description copied from interface:MultiSegmentSequenceRetrieve the Stretch Best Fit DPE- Specified by:
bestFitDPEin interfaceMultiSegmentSequence- Parameters:
stretchBestFitResponse- Stretch Best Fit Weighted Response Values- Returns:
- The Stretch Best Fit DPE
- Throws:
java.lang.Exception- Thrown if the Stretch Best Fit DPE cannot be computed
-
msm
Description copied from interface:MultiSegmentSequenceRetrieve the Merge Stretch Manager if it exists.- Specified by:
msmin interfaceMultiSegmentSequence- Returns:
- The Merge Stretch Manager
-
displayString
public java.lang.String displayString()Description copied from interface:MultiSegmentSequenceDisplay the Segments- Specified by:
displayStringin interfaceMultiSegmentSequence- Returns:
- The Segments String
-