HazardJumpEvaluator.java

  1. package org.drip.measure.dynamics;

  2. /*!
  3.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  4.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  5.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  6.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  7.  *
  8.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  9.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  10.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  11.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  12.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  13.  *      and computational support.
  14.  *  
  15.  *      https://lakshmidrip.github.io/DROP/
  16.  *  
  17.  *  DROP is composed of three modules:
  18.  *  
  19.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  20.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  21.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  22.  *
  23.  *  DROP Product Core implements libraries for the following:
  24.  *  - Fixed Income Analytics
  25.  *  - Loan Analytics
  26.  *  - Transaction Cost Analytics
  27.  *
  28.  *  DROP Portfolio Core implements libraries for the following:
  29.  *  - Asset Allocation Analytics
  30.  *  - Asset Liability Management Analytics
  31.  *  - Capital Estimation Analytics
  32.  *  - Exposure Analytics
  33.  *  - Margin Analytics
  34.  *  - XVA Analytics
  35.  *
  36.  *  DROP Computational Core implements libraries for the following:
  37.  *  - Algorithm Support
  38.  *  - Computation Support
  39.  *  - Function Analysis
  40.  *  - Model Validation
  41.  *  - Numerical Analysis
  42.  *  - Numerical Optimizer
  43.  *  - Spline Builder
  44.  *  - Statistical Learning
  45.  *
  46.  *  Documentation for DROP is Spread Over:
  47.  *
  48.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  49.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  50.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  51.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  52.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  53.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  54.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  55.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  56.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  57.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  58.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  59.  *
  60.  *  Licensed under the Apache License, Version 2.0 (the "License");
  61.  *      you may not use this file except in compliance with the License.
  62.  *  
  63.  *  You may obtain a copy of the License at
  64.  *      http://www.apache.org/licenses/LICENSE-2.0
  65.  *  
  66.  *  Unless required by applicable law or agreed to in writing, software
  67.  *      distributed under the License is distributed on an "AS IS" BASIS,
  68.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  69.  *  
  70.  *  See the License for the specific language governing permissions and
  71.  *      limitations under the License.
  72.  */

  73. /**
  74.  * <i>HazardJumpEvaluator</i> implements the Hazard Jump Process Point Event Indication Evaluator that guides
  75.  * the Single Factor Jump-Termination Random Process Variable Evolution.
  76.  *
  77.  *  <br><br>
  78.  *  <ul>
  79.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  80.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
  81.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/measure/README.md">R<sup>d</sup> Continuous/Discrete Probability Measures</a></li>
  82.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/measure/dynamics/README.md">Jump Diffusion Evolution Evaluator Variants</a></li>
  83.  *  </ul>
  84.  *
  85.  * @author Lakshmi Krishnamurthy
  86.  */

  87. public class HazardJumpEvaluator extends org.drip.measure.dynamics.SingleJumpEvaluator {
  88.     private double _dblMagnitude = java.lang.Double.NaN;
  89.     private double _dblHazardRate = java.lang.Double.NaN;

  90.     /**
  91.      * Generate a Standard Instance of HazardJumpEvaluator
  92.      *
  93.      * @param dblHazardRate The Hazard Rate
  94.      * @param dblMagnitude The Magnitude
  95.      *
  96.      * @return The Standard Instance of HazardJumpEvaluator
  97.      */

  98.     public static final HazardJumpEvaluator Standard (
  99.         final double dblHazardRate,
  100.         final double dblMagnitude)
  101.     {
  102.         org.drip.measure.dynamics.LocalEvaluator leDensity = new org.drip.measure.dynamics.LocalEvaluator() {
  103.             @Override public double value (
  104.                 final org.drip.measure.realization.JumpDiffusionVertex jdv)
  105.                 throws java.lang.Exception
  106.             {
  107.                 return -1. * dblHazardRate * java.lang.Math.exp (-1. * dblHazardRate);
  108.             }
  109.         };

  110.         org.drip.measure.dynamics.LocalEvaluator leMagnitude = new org.drip.measure.dynamics.LocalEvaluator()
  111.         {
  112.             @Override public double value (
  113.                 final org.drip.measure.realization.JumpDiffusionVertex jdv)
  114.                 throws java.lang.Exception
  115.             {
  116.                 return dblMagnitude;
  117.             }
  118.         };

  119.         try {
  120.             return new HazardJumpEvaluator (dblHazardRate, dblMagnitude, leDensity, leMagnitude);
  121.         } catch (java.lang.Exception e) {
  122.             e.printStackTrace();
  123.         }

  124.         return null;
  125.     }

  126.     private HazardJumpEvaluator (
  127.         final double dblHazardRate,
  128.         final double dblMagnitude,
  129.         final org.drip.measure.dynamics.LocalEvaluator leDensity,
  130.         final org.drip.measure.dynamics.LocalEvaluator leMagnitude)
  131.         throws java.lang.Exception
  132.     {
  133.         super (leDensity, leMagnitude);

  134.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblHazardRate = dblHazardRate) || 0. > _dblHazardRate
  135.             || !org.drip.numerical.common.NumberUtil.IsValid (_dblMagnitude = dblMagnitude) || 0. >
  136.                 _dblMagnitude)
  137.             throw new java.lang.Exception ("HazardJumpEvaluator Constructor => Invalid Inputs");
  138.     }

  139.     /**
  140.      * Retrieve the Hazard Rate
  141.      *
  142.      * @return The Hazard Rate
  143.      */

  144.     public double hazardRate()
  145.     {
  146.         return _dblHazardRate;
  147.     }

  148.     /**
  149.      * Retrieve the Magnitude
  150.      *
  151.      * @return The Magnitude
  152.      */

  153.     public double magnitude()
  154.     {
  155.         return _dblMagnitude;
  156.     }
  157. }