BuiltInEntry.java

  1. package org.drip.function.e2erf;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

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

  74. /**
  75.  * <i>BuiltInEntry</i> implements E<sub>2</sub> Entries of the Built-in Table of erf and erfc Values. The
  76.  * References are:
  77.  *
  78.  * <br><br>
  79.  *  <ul>
  80.  *      <li>
  81.  *          Abramowitz, M., and I. A. Stegun (2007): <i>Handbook of Mathematics Functions</i> <b>Dover Book
  82.  *              on Mathematics</b>
  83.  *      </li>
  84.  *      <li>
  85.  *          Chang, S. H., P. C. Cosman, L. B. Milstein (2011): Chernoff-Type Bounds for Gaussian Error
  86.  *              Function <i>IEEE Transactions on Communications</i> <b>59 (11)</b> 2939-2944
  87.  *      </li>
  88.  *      <li>
  89.  *          Cody, W. J. (1991): Algorithm 715: SPECFUN – A Portable FORTRAN Package of Special Function
  90.  *              Routines and Test Drivers <i>ACM Transactions on Mathematical Software</i> <b>19 (1)</b>
  91.  *              22-32
  92.  *      </li>
  93.  *      <li>
  94.  *          Schopf, H. M., and P. H. Supancic (2014): On Burmann’s Theorem and its Application to Problems of
  95.  *              Linear and Non-linear Heat Transfer and Diffusion
  96.  *              https://www.mathematica-journal.com/2014/11/on-burmanns-theorem-and-its-application-to-problems-of-linear-and-nonlinear-heat-transfer-and-diffusion/#more-39602/
  97.  *      </li>
  98.  *      <li>
  99.  *          Wikipedia (2019): Error Function https://en.wikipedia.org/wiki/Error_function
  100.  *      </li>
  101.  *  </ul>
  102.  *
  103.  *  <br><br>
  104.  *  <ul>
  105.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  106.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
  107.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/function/README.md">R<sup>d</sup> To R<sup>d</sup> Function Analysis</a></li>
  108.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/function/e2erf/README.md">E<sub>2</sub> erf and erf<sup>-1</sup> Implementations</a></li>
  109.  *  </ul>
  110.  *
  111.  * @author Lakshmi Krishnamurthy
  112.  */

  113. public class BuiltInEntry
  114. {
  115.     private double _erf = java.lang.Double.NaN;
  116.     private double _erfc = java.lang.Double.NaN;

  117.     /**
  118.      * Generate a Table of Built-in E<sub>2</sub> erf/erfc Entries
  119.      *
  120.      * @return The Table of Built-in E<sub>2</sub> erf/erfc Entries
  121.      */

  122.     public static final java.util.Map<java.lang.Double, BuiltInEntry> Table()
  123.     {
  124.         java.util.Map<java.lang.Double, BuiltInEntry> builtInEntryTable = new
  125.             java.util.TreeMap<java.lang.Double, BuiltInEntry>();

  126.         try
  127.         {
  128.             builtInEntryTable.put (
  129.                 0.00,
  130.                 new BuiltInEntry (
  131.                     0.000000000,
  132.                     1.000000000
  133.                 )
  134.             );

  135.             builtInEntryTable.put (
  136.                 0.02,
  137.                 new BuiltInEntry (
  138.                     0.022564575,
  139.                     0.977435425
  140.                 )
  141.             );

  142.             builtInEntryTable.put (
  143.                 0.04,
  144.                 new BuiltInEntry (
  145.                     0.045111106,
  146.                     0.954888894
  147.                 )
  148.             );

  149.             builtInEntryTable.put (
  150.                 0.06,
  151.                 new BuiltInEntry (
  152.                     0.067621594,
  153.                     0.932378406
  154.                 )
  155.             );

  156.             builtInEntryTable.put (
  157.                 0.08,
  158.                 new BuiltInEntry (
  159.                     0.090078126,
  160.                     0.909921874
  161.                 )
  162.             );

  163.             builtInEntryTable.put (
  164.                 0.10,
  165.                 new BuiltInEntry (
  166.                     0.112462916,
  167.                     0.887537084
  168.                 )
  169.             );

  170.             builtInEntryTable.put (
  171.                 0.20,
  172.                 new BuiltInEntry (
  173.                     0.222792589,
  174.                     0.777297411
  175.                 )
  176.             );

  177.             builtInEntryTable.put (
  178.                 0.30,
  179.                 new BuiltInEntry (
  180.                     0.328626759,
  181.                     0.671373241
  182.                 )
  183.             );

  184.             builtInEntryTable.put (
  185.                 0.40,
  186.                 new BuiltInEntry (
  187.                     0.428392355,
  188.                     0.571607645
  189.                 )
  190.             );

  191.             builtInEntryTable.put (
  192.                 0.50,
  193.                 new BuiltInEntry (
  194.                     0.520499878,
  195.                     0.479500122
  196.                 )
  197.             );

  198.             builtInEntryTable.put (
  199.                 0.60,
  200.                 new BuiltInEntry (
  201.                     0.603856091,
  202.                     0.396143909
  203.                 )
  204.             );

  205.             builtInEntryTable.put (
  206.                 0.70,
  207.                 new BuiltInEntry (
  208.                     0.677801194,
  209.                     0.322198806
  210.                 )
  211.             );

  212.             builtInEntryTable.put (
  213.                 0.80,
  214.                 new BuiltInEntry (
  215.                     0.742100965,
  216.                     0.257899035
  217.                 )
  218.             );

  219.             builtInEntryTable.put (
  220.                 0.90,
  221.                 new BuiltInEntry (
  222.                     0.796908212,
  223.                     0.203091788
  224.                 )
  225.             );

  226.             builtInEntryTable.put (
  227.                 1.00,
  228.                 new BuiltInEntry (
  229.                     0.842700793,
  230.                     0.157299207
  231.                 )
  232.             );

  233.             builtInEntryTable.put (
  234.                 1.10,
  235.                 new BuiltInEntry (
  236.                     0.880205070,
  237.                     0.119794930
  238.                 )
  239.             );

  240.             builtInEntryTable.put (
  241.                 1.20,
  242.                 new BuiltInEntry (
  243.                     0.910313978,
  244.                     0.089686022
  245.                 )
  246.             );

  247.             builtInEntryTable.put (
  248.                 1.30,
  249.                 new BuiltInEntry (
  250.                     0.934007945,
  251.                     0.065992055
  252.                 )
  253.             );

  254.             builtInEntryTable.put (
  255.                 1.40,
  256.                 new BuiltInEntry (
  257.                     0.952285120,
  258.                     0.047714880
  259.                 )
  260.             );

  261.             builtInEntryTable.put (
  262.                 1.50,
  263.                 new BuiltInEntry (
  264.                     0.966105146,
  265.                     0.033894854
  266.                 )
  267.             );

  268.             builtInEntryTable.put (
  269.                 1.60,
  270.                 new BuiltInEntry (
  271.                     0.976348383,
  272.                     0.023651617
  273.                 )
  274.             );

  275.             builtInEntryTable.put (
  276.                 1.70,
  277.                 new BuiltInEntry (
  278.                     0.983790459,
  279.                     0.016209541
  280.                 )
  281.             );

  282.             builtInEntryTable.put (
  283.                 1.80,
  284.                 new BuiltInEntry (
  285.                     0.989090502,
  286.                     0.010909498
  287.                 )
  288.             );

  289.             builtInEntryTable.put (
  290.                 1.90,
  291.                 new BuiltInEntry (
  292.                     0.992790429,
  293.                     0.007209571
  294.                 )
  295.             );

  296.             builtInEntryTable.put (
  297.                 2.00,
  298.                 new BuiltInEntry (
  299.                     0.995322265,
  300.                     0.004677735
  301.                 )
  302.             );

  303.             builtInEntryTable.put (
  304.                 2.10,
  305.                 new BuiltInEntry (
  306.                     0.997020533,
  307.                     0.002979467
  308.                 )
  309.             );

  310.             builtInEntryTable.put (
  311.                 2.20,
  312.                 new BuiltInEntry (
  313.                     0.998137154,
  314.                     0.001862846
  315.                 )
  316.             );

  317.             builtInEntryTable.put (
  318.                 2.30,
  319.                 new BuiltInEntry (
  320.                     0.998856823,
  321.                     0.001143177
  322.                 )
  323.             );

  324.             builtInEntryTable.put (
  325.                 2.40,
  326.                 new BuiltInEntry (
  327.                     0.999311486,
  328.                     0.000688514
  329.                 )
  330.             );

  331.             builtInEntryTable.put (
  332.                 2.50,
  333.                 new BuiltInEntry (
  334.                     0.999593048,
  335.                     0.000406952
  336.                 )
  337.             );

  338.             builtInEntryTable.put (
  339.                 3.00,
  340.                 new BuiltInEntry (
  341.                     0.999977910,
  342.                     0.000022090
  343.                 )
  344.             );

  345.             builtInEntryTable.put (
  346.                 3.50,
  347.                 new BuiltInEntry (
  348.                     0.999999257,
  349.                     0.000000743
  350.                 )
  351.             );

  352.             return builtInEntryTable;
  353.         }
  354.         catch (java.lang.Exception e)
  355.         {
  356.             e.printStackTrace();
  357.         }

  358.         return null;
  359.     }

  360.     /**
  361.      * BuiltInEntry Constructor
  362.      *
  363.      * @param erf E<sub>2</sub> erf Value
  364.      * @param erfc E<sub>2</sub> erfc Value
  365.      *
  366.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  367.      */

  368.     public BuiltInEntry (
  369.         final double erf,
  370.         final double erfc)
  371.         throws java.lang.Exception
  372.     {
  373.         if (!org.drip.numerical.common.NumberUtil.IsValid (_erf = erf) ||
  374.             !org.drip.numerical.common.NumberUtil.IsValid (_erfc = erfc))
  375.         {
  376.             throw new java.lang.Exception ("BuiltInE2Entry Constructor => Invalid Inputs");
  377.         }
  378.     }

  379.     /**
  380.      * Retrieve the E<sub>2</sub> erf
  381.      *
  382.      * @return The E<sub>2</sub> erf
  383.      */

  384.     public double erf()
  385.     {
  386.         return _erf;
  387.     }

  388.     /**
  389.      * Retrieve the E<sub>2</sub> erfc
  390.      *
  391.      * @return The E<sub>2</sub> erfc
  392.      */

  393.     public double erfc()
  394.     {
  395.         return _erfc;
  396.     }
  397. }