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 double
bestFitDPE(StretchBestFitResponse stretchBestFitResponse)
Retrieve the Stretch Best Fit DPEdouble
calcLeftEdgeDerivative(int order)
Calculate the Derivative of the requested order at the Left Edge of the Stretchdouble
calcRightEdgeDerivative(int order)
Calculate the Derivative of the requested order at the right Edge of the StretchSegmentPredictorResponseDerivative
calcSPRD(double predictorOrdinate)
Calculate the SegmentPredictorResponseDerivative at the specified Predictor OrdinateCalibratableMultiSegmentSequence
clipLeft(java.lang.String name, double predictorOrdinate)
Generate a new Stretch by clipping all the Segments to the Left of the specified Predictor Ordinate.CalibratableMultiSegmentSequence
clipRight(java.lang.String name, double predictorOrdinate)
Generate a new Stretch by clipping all the Segments to the Right of the specified Predictor Ordinate.int
containingIndex(double predictorOrdinate, boolean includeLeft, boolean includeRight)
Return the Index for the Segment containing specified Predictor Ordinatedouble
curvatureDPE()
Retrieve the Span Curvature DPEjava.lang.String
displayString()
Display the Segmentsdouble
evaluate(double leftSlope)
Evaluate for the given variatedouble
getLeftPredictorOrdinateEdge()
Return the Left Predictor Ordinate Edgedouble
getRightPredictorOrdinateEdge()
Return the Right Predictor Ordinate Edgeboolean
in(double predictorOrdinate)
Check if the Predictor Ordinate is in the Stretch Rangedouble
integrate(double begin, double end)
Integrate over the given rangeboolean
isCoMonotone(double[] measuredResponseArray)
Verify whether the Stretch mini-max Behavior matches the Measurementboolean
isKnot(double predictorOrdinate)
Is the given Predictor Ordinate a Knot Locationboolean
isLocallyMonotone()
Indicate if all the comprising Segments are MonotoneWengertJacobian
jackDResponseDCalibrationInput(double predictorOrdinate, int order)
Calculate the Response Derivative to the Calibration Inputs at the specified OrdinateWengertJacobian
jackDResponseDManifestMeasure(java.lang.String manifestMeasure, double predictorOrdinate, int order)
Calculate the Response Derivative to the Manifest Measure at the specified Ordinatedouble
lengthDPE()
Retrieve the Span Length DPEMonotonocity
monotoneType(double predictorOrdinate)
Identify the Monotone Type for the Segment underlying the given Predictor OrdinateMergeSubStretchManager
msm()
Retrieve the Merge Stretch Manager if it exists.java.lang.String
name()
Retrieve the Stretch Nameboolean
resetNode(int predictorOrdinateIndex, double responseReset)
Reset the Predictor Ordinate Node Index with the given Responseboolean
resetNode(int predictorOrdinateIndex, SegmentResponseValueConstraint resetSegmentResponseValueConstraint)
Reset the Predictor Ordinate Node Index with the given Segment Constraintdouble
responseValue(double predictorOrdinate)
Calculate the Response Value at the given Predictor Ordinatedouble
responseValueDerivative(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 Segmentsboolean
setLeftNode(double stretchLeftResponse, double stretchLeftResponseSlope, double stretchRightResponse, StretchBestFitResponse stretchBestFitResponse)
Set the Slope at the left Edge of the Stretchboolean
setup(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.boolean
setup(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.boolean
setup(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.boolean
setup(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.boolean
setupHermite(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.R1ToR1
toAU()
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, poleResidue
Methods 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:MultiSegmentSequence
Retrieve the Stretch Name- Specified by:
name
in interfaceMultiSegmentSequence
- Returns:
- The Stretch Name
-
segments
Description copied from interface:MultiSegmentSequence
Retrieve the Stretch Segments- Specified by:
segments
in interfaceMultiSegmentSequence
- Returns:
- The Stretch Segments
-
segmentBuilderControl
Description copied from interface:MultiSegmentSequence
Retrieve the Segment Builder Parameters- Specified by:
segmentBuilderControl
in interfaceMultiSegmentSequence
- Returns:
- The Segment Builder Parameters
-
setup
Description copied from interface:MultiSegmentSequence
Set 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:
setup
in 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:MultiSegmentSequence
Set up (i.e., calibrate) the individual Segments in the Stretch to the Stretch Left Edge and the Target Constraints.- Specified by:
setup
in 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:MultiSegmentSequence
Set up (i.e., calibrate) the individual Segments in the Stretch to the Stretch Left Edge Response and the Target Constraints.- Specified by:
setup
in 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:SingleSegmentSequence
Set up (i.e., calibrate) the individual Segments in the Stretch to the Response Values corresponding to each Segment Predictor right Ordinate.- Specified by:
setup
in 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:MultiSegmentSequence
Set 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:
setupHermite
in 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:R1ToR1
Evaluate for the given variate -
integrate
public double integrate(double begin, double end) throws java.lang.ExceptionDescription copied from class:R1ToR1
Integrate over the given range -
setLeftNode
public boolean setLeftNode(double stretchLeftResponse, double stretchLeftResponseSlope, double stretchRightResponse, StretchBestFitResponse stretchBestFitResponse)Description copied from interface:MultiSegmentSequence
Set the Slope at the left Edge of the Stretch- Specified by:
setLeftNode
in 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:SingleSegmentSequence
Calculate the Response Value at the given Predictor Ordinate- Specified by:
responseValue
in 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:SingleSegmentSequence
Calculate the Response Value Derivative at the given Predictor Ordinate for the specified order- Specified by:
responseValueDerivative
in 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:MultiSegmentSequence
Calculate the SegmentPredictorResponseDerivative at the specified Predictor Ordinate- Specified by:
calcSPRD
in interfaceMultiSegmentSequence
- Parameters:
predictorOrdinate
- The Predictor Ordinate- Returns:
- The Computed SegmentPredictorResponseDerivative
-
jackDResponseDCalibrationInput
Description copied from interface:SingleSegmentSequence
Calculate the Response Derivative to the Calibration Inputs at the specified Ordinate- Specified by:
jackDResponseDCalibrationInput
in 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:SingleSegmentSequence
Calculate the Response Derivative to the Manifest Measure at the specified Ordinate- Specified by:
jackDResponseDManifestMeasure
in 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:SingleSegmentSequence
Identify the Monotone Type for the Segment underlying the given Predictor Ordinate- Specified by:
monotoneType
in interfaceSingleSegmentSequence
- Parameters:
predictorOrdinate
- Predictor Ordinate- Returns:
- Segment Monotone Type
-
isLocallyMonotone
public boolean isLocallyMonotone() throws java.lang.ExceptionDescription copied from interface:SingleSegmentSequence
Indicate if all the comprising Segments are Monotone- Specified by:
isLocallyMonotone
in 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:SingleSegmentSequence
Verify whether the Stretch mini-max Behavior matches the Measurement- Specified by:
isCoMonotone
in 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:SingleSegmentSequence
Is the given Predictor Ordinate a Knot Location- Specified by:
isKnot
in 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:MultiSegmentSequence
Calculate the Derivative of the requested order at the Left Edge of the Stretch- Specified by:
calcLeftEdgeDerivative
in 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:MultiSegmentSequence
Calculate the Derivative of the requested order at the right Edge of the Stretch- Specified by:
calcRightEdgeDerivative
in 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:SingleSegmentSequence
Reset the Predictor Ordinate Node Index with the given Response- Specified by:
resetNode
in 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:SingleSegmentSequence
Reset the Predictor Ordinate Node Index with the given Segment Constraint- Specified by:
resetNode
in 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:SingleSegmentSequence
Convert the Segment Sequence into an AbstractUnivariate Instance- Specified by:
toAU
in interfaceSingleSegmentSequence
- Returns:
- The AbstractUnivariate Instance
-
in
public boolean in(double predictorOrdinate) throws java.lang.ExceptionDescription copied from interface:MultiSegmentSequence
Check if the Predictor Ordinate is in the Stretch Range- Specified by:
in
in 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:SingleSegmentSequence
Return the Left Predictor Ordinate Edge- Specified by:
getLeftPredictorOrdinateEdge
in interfaceSingleSegmentSequence
- Returns:
- The Left Predictor Ordinate Edge
-
getRightPredictorOrdinateEdge
public double getRightPredictorOrdinateEdge()Description copied from interface:SingleSegmentSequence
Return the Right Predictor Ordinate Edge- Specified by:
getRightPredictorOrdinateEdge
in interfaceSingleSegmentSequence
- Returns:
- The Right Predictor Ordinate Edge
-
containingIndex
public int containingIndex(double predictorOrdinate, boolean includeLeft, boolean includeRight) throws java.lang.ExceptionDescription copied from interface:MultiSegmentSequence
Return the Index for the Segment containing specified Predictor Ordinate- Specified by:
containingIndex
in 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:MultiSegmentSequence
Generate a new Stretch by clipping all the Segments to the Left of the specified Predictor Ordinate. Smoothness Constraints will be maintained.- Specified by:
clipLeft
in 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:MultiSegmentSequence
Generate a new Stretch by clipping all the Segments to the Right of the specified Predictor Ordinate. Smoothness Constraints will be maintained.- Specified by:
clipRight
in 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:MultiSegmentSequence
Retrieve the Span Curvature DPE- Specified by:
curvatureDPE
in 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:MultiSegmentSequence
Retrieve the Span Length DPE- Specified by:
lengthDPE
in interfaceMultiSegmentSequence
- Returns:
- The Span Length DPE
- Throws:
java.lang.Exception
- Thrown if the Span Length DPE cannot be computed
-
bestFitDPE
Description copied from interface:MultiSegmentSequence
Retrieve the Stretch Best Fit DPE- Specified by:
bestFitDPE
in 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:MultiSegmentSequence
Retrieve the Merge Stretch Manager if it exists.- Specified by:
msm
in interfaceMultiSegmentSequence
- Returns:
- The Merge Stretch Manager
-
displayString
public java.lang.String displayString()Description copied from interface:MultiSegmentSequence
Display the Segments- Specified by:
displayString
in interfaceMultiSegmentSequence
- Returns:
- The Segments String
-