AbramowitzStegunSeriesGenerator.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>AbramowitzStegunSeriesGenerator</i> implements the E<sub>2</sub> erf Abramowitz-Stegun Variant of
  76.  * Series Term Generator. The 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 AbramowitzStegunSeriesGenerator extends org.drip.numerical.estimation.R1ToR1Series
  114. {

  115.     /**
  116.      * Construct a Inverse Polynomial Degree 4 Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  117.      *
  118.      * @return Inverse Polynomial Degree 4 Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  119.      */

  120.     public static final AbramowitzStegunSeriesGenerator InversePolynomial4()
  121.     {
  122.         java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  123.             java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  124.         termWeightMap.put (
  125.             0,
  126.             1.000000
  127.         );

  128.         termWeightMap.put (
  129.             1,
  130.             0.278393
  131.         );

  132.         termWeightMap.put (
  133.             2,
  134.             0.230289
  135.         );

  136.         termWeightMap.put (
  137.             3,
  138.             0.000972
  139.         );

  140.         termWeightMap.put (
  141.             4,
  142.             0.078108
  143.         );

  144.         try
  145.         {
  146.             return new AbramowitzStegunSeriesGenerator (
  147.                 org.drip.numerical.estimation.R1ToR1SeriesTerm.Taylor(),
  148.                 termWeightMap
  149.             );
  150.         }
  151.         catch (java.lang.Exception e)
  152.         {
  153.             e.printStackTrace();
  154.         }

  155.         return null;
  156.     }

  157.     /**
  158.      * Construct a Mixed Polynomial Degree 3 Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  159.      *
  160.      * @return Mixed Polynomial Degree 3 Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  161.      */

  162.     public static final AbramowitzStegunSeriesGenerator MixedPolynomial3()
  163.     {
  164.         java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  165.             java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  166.         termWeightMap.put (
  167.             1,
  168.             0.3480242
  169.         );

  170.         termWeightMap.put (
  171.             2,
  172.             -0.0958798
  173.         );

  174.         termWeightMap.put (
  175.             3,
  176.             0.7478556
  177.         );

  178.         try
  179.         {
  180.             return new AbramowitzStegunSeriesGenerator (
  181.                 org.drip.numerical.estimation.R1ToR1SeriesTerm.Taylor(),
  182.                 termWeightMap
  183.             );
  184.         }
  185.         catch (java.lang.Exception e)
  186.         {
  187.             e.printStackTrace();
  188.         }

  189.         return null;
  190.     }

  191.     /**
  192.      * Construct a Inverse Polynomial Degree 6 Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  193.      *
  194.      * @return Inverse Polynomial Degree 6 Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  195.      */

  196.     public static final AbramowitzStegunSeriesGenerator InversePolynomial6()
  197.     {
  198.         java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  199.             java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  200.         termWeightMap.put (
  201.             0,
  202.             1.0000000000
  203.         );

  204.         termWeightMap.put (
  205.             1,
  206.             0.0705230784
  207.         );

  208.         termWeightMap.put (
  209.             2,
  210.             0.0422820123
  211.         );

  212.         termWeightMap.put (
  213.             3,
  214.             0.0092705272
  215.         );

  216.         termWeightMap.put (
  217.             4,
  218.             0.0001520143
  219.         );

  220.         termWeightMap.put (
  221.             5,
  222.             0.0002765672
  223.         );

  224.         termWeightMap.put (
  225.             6,
  226.             0.0000430638
  227.         );

  228.         try
  229.         {
  230.             return new AbramowitzStegunSeriesGenerator (
  231.                 org.drip.numerical.estimation.R1ToR1SeriesTerm.Taylor(),
  232.                 termWeightMap
  233.             );
  234.         }
  235.         catch (java.lang.Exception e)
  236.         {
  237.             e.printStackTrace();
  238.         }

  239.         return null;
  240.     }

  241.     /**
  242.      * Construct a Mixed Polynomial Degree 5 Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  243.      *
  244.      * @return Mixed Polynomial Degree 5 Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  245.      */

  246.     public static final AbramowitzStegunSeriesGenerator MixedPolynomial5()
  247.     {
  248.         java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  249.             java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  250.         termWeightMap.put (
  251.             1,
  252.             0.254829592
  253.         );

  254.         termWeightMap.put (
  255.             2,
  256.             -0.284496736
  257.         );

  258.         termWeightMap.put (
  259.             3,
  260.             1.421413741
  261.         );

  262.         termWeightMap.put (
  263.             4,
  264.             -1.453152027
  265.         );

  266.         termWeightMap.put (
  267.             5,
  268.             1.061405429
  269.         );

  270.         try
  271.         {
  272.             return new AbramowitzStegunSeriesGenerator (
  273.                 org.drip.numerical.estimation.R1ToR1SeriesTerm.Taylor(),
  274.                 termWeightMap
  275.             );
  276.         }
  277.         catch (java.lang.Exception e)
  278.         {
  279.             e.printStackTrace();
  280.         }

  281.         return null;
  282.     }

  283.     /**
  284.      * Construct the Numerical Recipes Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  285.      *
  286.      * @return Numerical Recipes Version of E<sub>2</sub> erf AbramowitzStegunSeriesGenerator
  287.      */

  288.     public static final AbramowitzStegunSeriesGenerator NumericalRecipe2007()
  289.     {
  290.         java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  291.             java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  292.         termWeightMap.put (
  293.             0,
  294.             -1.26551223
  295.         );

  296.         termWeightMap.put (
  297.             1,
  298.             1.00002368
  299.         );

  300.         termWeightMap.put (
  301.             2,
  302.             0.37409196
  303.         );

  304.         termWeightMap.put (
  305.             3,
  306.             0.09678418
  307.         );

  308.         termWeightMap.put (
  309.             4,
  310.             -0.18628806
  311.         );

  312.         termWeightMap.put (
  313.             5,
  314.             0.27886807
  315.         );

  316.         termWeightMap.put (
  317.             6,
  318.             -1.13520398
  319.         );

  320.         termWeightMap.put (
  321.             7,
  322.             1.48851587
  323.         );

  324.         termWeightMap.put (
  325.             8,
  326.             -0.82215223
  327.         );

  328.         termWeightMap.put (
  329.             9,
  330.             0.17087277
  331.         );

  332.         try
  333.         {
  334.             return new AbramowitzStegunSeriesGenerator (
  335.                 org.drip.numerical.estimation.R1ToR1SeriesTerm.Taylor(),
  336.                 termWeightMap
  337.             );
  338.         }
  339.         catch (java.lang.Exception e)
  340.         {
  341.             e.printStackTrace();
  342.         }

  343.         return null;
  344.     }

  345.     /**
  346.      * AbramowitzStegunSeriesGenerator Constructor
  347.      *
  348.      * @param r1ToR1SeriesTerm R<sup>1</sup> To R<sup>1</sup> Series Expansion Term
  349.      * @param termWeightMap Error Term Weight Map
  350.      *
  351.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  352.      */

  353.     public AbramowitzStegunSeriesGenerator (
  354.         final org.drip.numerical.estimation.R1ToR1SeriesTerm r1ToR1SeriesTerm,
  355.         final java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap)
  356.         throws java.lang.Exception
  357.     {
  358.         super (
  359.             r1ToR1SeriesTerm,
  360.             false,
  361.             termWeightMap
  362.         );
  363.     }
  364. }