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
  • Constructor Details

    • CalibratableMultiSegmentSequence

      public CalibratableMultiSegmentSequence​(java.lang.String name, LatentStateResponseModel[] latentStateResponseModelArray, SegmentCustomBuilderControl[] segmentCustomBuilderControlArray) throws java.lang.Exception
      CalibratableMultiSegmentSequence constructor - Construct a sequence of Basis Spline Segments
      Parameters:
      name - Name of the Stretch
      latentStateResponseModelArray - Array of Segments
      segmentCustomBuilderControlArray - 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 interface MultiSegmentSequence
      Returns:
      The Stretch Name
    • segments

      public LatentStateResponseModel[] segments()
      Description copied from interface: MultiSegmentSequence
      Retrieve the Stretch Segments
      Specified by:
      segments in interface MultiSegmentSequence
      Returns:
      The Stretch Segments
    • segmentBuilderControl

      public SegmentCustomBuilderControl[] segmentBuilderControl()
      Description copied from interface: MultiSegmentSequence
      Retrieve the Segment Builder Parameters
      Specified by:
      segmentBuilderControl in interface MultiSegmentSequence
      Returns:
      The Segment Builder Parameters
    • setup

      public boolean setup​(SegmentSequenceBuilder segmentSequenceBuilder, int calibrationDetail)
      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 interface MultiSegmentSequence
      Parameters:
      segmentSequenceBuilder - The Segment Sequence Builder Instance
      calibrationDetail - 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 interface MultiSegmentSequence
      Parameters:
      leadingSegmentResponseValueConstraint - Stretch Left-most Segment Response Value Constraint
      segmentResponseValueConstraintArray - Array of Segment Response Value Constraints
      stretchBestFitResponse - Stretch Fitness Weighted Response
      boundarySettings - The Calibration Boundary Condition
      calibrationDetail - 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 interface MultiSegmentSequence
      Parameters:
      leftStretchResponseValue - Stretch Left-most Response Value
      segmentResponseValueConstraintArray - Array of Segment Response Value Constraints
      stretchBestFitResponse - Stretch Best Fit Weighted Response Values
      bBoundarySettings - The Calibration Boundary Condition
      calibrationDetail - 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 interface SingleSegmentSequence
      Parameters:
      leftStretchResponseValue - Stretch Left-most Response
      segmentRightResponseValueArray - Array of Segment Right Edge Responses
      stretchBestFitResponse - Stretch Fitness Weighted Response
      boundarySettings - The Calibration Boundary Condition
      calibrationDetail - 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 interface MultiSegmentSequence
      Parameters:
      leftSegmentPredictorResponseDerivativeArray - Array of Left Segment Edge Values
      rightSegmentPredictorResponseDerivativeArray - Array of Right Segment Edge Values
      segmentResponseValueConstraintGrid - Double Array of Constraints - Outer Index corresponds to Segment Index, and the Inner Index to Constraint Array within each Segment
      sbfr - Stretch Fitness Weighted Response
      iSetupMode - 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.Exception
      Description copied from class: R1ToR1
      Evaluate for the given variate
      Specified by:
      evaluate in class R1ToR1
      Parameters:
      leftSlope - Variate
      Returns:
      Returns the calculated value
      Throws:
      java.lang.Exception - Thrown if evaluation cannot be done
    • integrate

      public double integrate​(double begin, double end) throws java.lang.Exception
      Description copied from class: R1ToR1
      Integrate over the given range
      Overrides:
      integrate in class R1ToR1
      Parameters:
      begin - Range Begin
      end - Range End
      Returns:
      The Integrated Value
      Throws:
      java.lang.Exception - Thrown if evaluation cannot be done
    • 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 interface MultiSegmentSequence
      Parameters:
      stretchLeftResponse - Response Value at the Left Edge of the Stretch
      stretchLeftResponseSlope - Response Slope Value at the Left Edge of the Stretch
      stretchRightResponse - Response Value at the Right Edge of the Stretch
      stretchBestFitResponse - Stretch Fitness Weighted Response
      Returns:
      TRUE - Left slope successfully set
    • responseValue

      public double responseValue​(double predictorOrdinate) throws java.lang.Exception
      Description copied from interface: SingleSegmentSequence
      Calculate the Response Value at the given Predictor Ordinate
      Specified by:
      responseValue in interface SingleSegmentSequence
      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.Exception
      Description copied from interface: SingleSegmentSequence
      Calculate the Response Value Derivative at the given Predictor Ordinate for the specified order
      Specified by:
      responseValueDerivative in interface SingleSegmentSequence
      Parameters:
      predictorOrdinate - Predictor Ordinate
      iOrder - Order the Derivative
      Returns:
      The Response Value
      Throws:
      java.lang.Exception - Thrown if the Response Value Derivative cannot be calculated
    • calcSPRD

      public SegmentPredictorResponseDerivative calcSPRD​(double predictorOrdinate)
      Description copied from interface: MultiSegmentSequence
      Calculate the SegmentPredictorResponseDerivative at the specified Predictor Ordinate
      Specified by:
      calcSPRD in interface MultiSegmentSequence
      Parameters:
      predictorOrdinate - The Predictor Ordinate
      Returns:
      The Computed SegmentPredictorResponseDerivative
    • jackDResponseDCalibrationInput

      public WengertJacobian jackDResponseDCalibrationInput​(double predictorOrdinate, int order)
      Description copied from interface: SingleSegmentSequence
      Calculate the Response Derivative to the Calibration Inputs at the specified Ordinate
      Specified by:
      jackDResponseDCalibrationInput in interface SingleSegmentSequence
      Parameters:
      predictorOrdinate - Predictor Ordinate
      order - 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 interface SingleSegmentSequence
      Parameters:
      manifestMeasure - Manifest Measure whose Sensitivity is sought
      predictorOrdinate - Predictor Ordinate
      order - Order of Derivative desired
      Returns:
      Jacobian of the Response Derivative to the Quote at the Ordinate
    • monotoneType

      public Monotonocity monotoneType​(double predictorOrdinate)
      Description copied from interface: SingleSegmentSequence
      Identify the Monotone Type for the Segment underlying the given Predictor Ordinate
      Specified by:
      monotoneType in interface SingleSegmentSequence
      Parameters:
      predictorOrdinate - Predictor Ordinate
      Returns:
      Segment Monotone Type
    • isLocallyMonotone

      public boolean isLocallyMonotone() throws java.lang.Exception
      Description copied from interface: SingleSegmentSequence
      Indicate if all the comprising Segments are Monotone
      Specified by:
      isLocallyMonotone in interface SingleSegmentSequence
      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.Exception
      Description copied from interface: SingleSegmentSequence
      Verify whether the Stretch mini-max Behavior matches the Measurement
      Specified by:
      isCoMonotone in interface SingleSegmentSequence
      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 interface SingleSegmentSequence
      Parameters:
      predictorOrdinate - Predictor Ordinate
      Returns:
      TRUE - Given Predictor Ordinate corresponds to a Knot
    • calcLeftEdgeDerivative

      public double calcLeftEdgeDerivative​(int order) throws java.lang.Exception
      Description copied from interface: MultiSegmentSequence
      Calculate the Derivative of the requested order at the Left Edge of the Stretch
      Specified by:
      calcLeftEdgeDerivative in interface MultiSegmentSequence
      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.Exception
      Description copied from interface: MultiSegmentSequence
      Calculate the Derivative of the requested order at the right Edge of the Stretch
      Specified by:
      calcRightEdgeDerivative in interface MultiSegmentSequence
      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 interface SingleSegmentSequence
      Parameters:
      predictorOrdinateIndex - The Predictor Ordinate Node Index whose Response is to be reset
      responseReset - 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 interface SingleSegmentSequence
      Parameters:
      predictorOrdinateIndex - The Predictor Ordinate Node Index whose Response is to be reset
      resetSegmentResponseValueConstraint - The Segment Constraint
      Returns:
      TRUE - Reset succeeded
    • toAU

      public R1ToR1 toAU()
      Description copied from interface: SingleSegmentSequence
      Convert the Segment Sequence into an AbstractUnivariate Instance
      Specified by:
      toAU in interface SingleSegmentSequence
      Returns:
      The AbstractUnivariate Instance
    • in

      public boolean in​(double predictorOrdinate) throws java.lang.Exception
      Description copied from interface: MultiSegmentSequence
      Check if the Predictor Ordinate is in the Stretch Range
      Specified by:
      in in interface MultiSegmentSequence
      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 interface SingleSegmentSequence
      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 interface SingleSegmentSequence
      Returns:
      The Right Predictor Ordinate Edge
    • containingIndex

      public int containingIndex​(double predictorOrdinate, boolean includeLeft, boolean includeRight) throws java.lang.Exception
      Description copied from interface: MultiSegmentSequence
      Return the Index for the Segment containing specified Predictor Ordinate
      Specified by:
      containingIndex in interface MultiSegmentSequence
      Parameters:
      predictorOrdinate - Predictor Ordinate
      includeLeft - TRUE - Less than or equal to the Left Predictor Ordinate
      includeRight - 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

      public CalibratableMultiSegmentSequence clipLeft​(java.lang.String name, double predictorOrdinate)
      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 interface MultiSegmentSequence
      Parameters:
      name - Name of the Clipped Stretch
      predictorOrdinate - Predictor Ordinate Left of which the Clipping is to be applied
      Returns:
      The Clipped Stretch
    • clipRight

      public CalibratableMultiSegmentSequence clipRight​(java.lang.String name, double predictorOrdinate)
      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 interface MultiSegmentSequence
      Parameters:
      name - Name of the Clipped Stretch
      predictorOrdinate - Predictor Ordinate Right of which the Clipping is to be applied
      Returns:
      The Clipped Stretch
    • curvatureDPE

      public double curvatureDPE() throws java.lang.Exception
      Description copied from interface: MultiSegmentSequence
      Retrieve the Span Curvature DPE
      Specified by:
      curvatureDPE in interface MultiSegmentSequence
      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.Exception
      Description copied from interface: MultiSegmentSequence
      Retrieve the Span Length DPE
      Specified by:
      lengthDPE in interface MultiSegmentSequence
      Returns:
      The Span Length DPE
      Throws:
      java.lang.Exception - Thrown if the Span Length DPE cannot be computed
    • bestFitDPE

      public double bestFitDPE​(StretchBestFitResponse stretchBestFitResponse) throws java.lang.Exception
      Description copied from interface: MultiSegmentSequence
      Retrieve the Stretch Best Fit DPE
      Specified by:
      bestFitDPE in interface MultiSegmentSequence
      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

      public MergeSubStretchManager msm()
      Description copied from interface: MultiSegmentSequence
      Retrieve the Merge Stretch Manager if it exists.
      Specified by:
      msm in interface MultiSegmentSequence
      Returns:
      The Merge Stretch Manager
    • displayString

      public java.lang.String displayString()
      Description copied from interface: MultiSegmentSequence
      Display the Segments
      Specified by:
      displayString in interface MultiSegmentSequence
      Returns:
      The Segments String