CumulativeSeries.java

  1. package org.drip.specialfunction.digamma;

  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>CumulativeSeries</i> implements the Cumulative Series for Digamma Estimation. The References are:
  76.  *
  77.  * <br><br>
  78.  *  <ul>
  79.  *      <li>
  80.  *          Abramowitz, M., and I. A. Stegun (2007): Handbook of Mathematics Functions <b>Dover Book on
  81.  *              Mathematics</b>
  82.  *      </li>
  83.  *      <li>
  84.  *          Blagouchine, I. V. (2018): Three Notes on Ser's and Hasse's Representations for the
  85.  *              Zeta-Functions https://arxiv.org/abs/1606.02044 <b>arXiv</b>
  86.  *      </li>
  87.  *      <li>
  88.  *          Mezo, I., and M. E. Hoffman (2017): Zeros of the Digamma Function and its Barnes G-function
  89.  *              Analogue <i>Integral Transforms and Special Functions</i> <b>28 (28)</b> 846-858
  90.  *      </li>
  91.  *      <li>
  92.  *          Whitaker, E. T., and G. N. Watson (1996): <i>A Course on Modern Analysis</i> <b>Cambridge
  93.  *              University Press</b> New York
  94.  *      </li>
  95.  *      <li>
  96.  *          Wikipedia (2019): Digamma Function https://en.wikipedia.org/wiki/Digamma_function
  97.  *      </li>
  98.  *  </ul>
  99.  *
  100.  *  <br><br>
  101.  *  <ul>
  102.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  103.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FunctionAnalysisLibrary.md">Function Analysis Library</a></li>
  104.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/specialfunction/README.md">Special Function Implementation Analysis</a></li>
  105.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/specialfunction/digamma/README.md">Estimation Techniques for Digamma Function</a></li>
  106.  *  </ul>
  107.  *
  108.  * @author Lakshmi Krishnamurthy
  109.  */

  110. public class CumulativeSeries
  111. {

  112.     /**
  113.      * Construct the R<sup>1</sup> To R<sup>1</sup> Infinite Abramowitz-Stegun (2007) Cumulative Series
  114.      *
  115.      * @param termCount Count of the Number of Terms
  116.      *
  117.      * @return The R<sup>1</sup> To R<sup>1</sup> Infinite Abramowitz-Stegun (2007) Cumulative Series
  118.      */

  119.     public static final org.drip.numerical.estimation.R1ToR1Series AbramowitzStegun2007 (
  120.         final int termCount)
  121.     {
  122.         try
  123.         {
  124.             java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  125.                 java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  126.             for (int termIndex = 1; termIndex <= termCount; ++termIndex)
  127.             {
  128.                 termWeightMap.put (
  129.                     termIndex,
  130.                     1.
  131.                 );
  132.             }

  133.             return new org.drip.numerical.estimation.R1ToR1Series (
  134.                 org.drip.specialfunction.digamma.CumulativeSeriesTerm.AbramowitzStegun2007(),
  135.                 false,
  136.                 termWeightMap
  137.             );
  138.         }
  139.         catch (java.lang.Exception e)
  140.         {
  141.             e.printStackTrace();
  142.         }

  143.         return null;
  144.     }

  145.     /**
  146.      * Construct the R<sup>1</sup> To R<sup>1</sup> Infinite Saddle Point Cumulative Series
  147.      *
  148.      * @param saddlePointFunction The Saddle Point Generation Function
  149.      * @param saddlePointCount The Saddle Point Count
  150.      *
  151.      * @return The R<sup>1</sup> To R<sup>1</sup> Infinite Saddle Point Cumulative Series
  152.      */

  153.     public static final org.drip.numerical.estimation.R1ToR1Series MezoHoffman2017 (
  154.         final org.drip.function.definition.R1ToR1 saddlePointFunction,
  155.         final int saddlePointCount)
  156.     {
  157.         try
  158.         {
  159.             java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  160.                 java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  161.             for (int termIndex = 0; termIndex <= saddlePointCount; ++termIndex)
  162.             {
  163.                 termWeightMap.put (
  164.                     termIndex,
  165.                     1.
  166.                 );
  167.             }

  168.             return new org.drip.numerical.estimation.R1ToR1Series (
  169.                 org.drip.specialfunction.digamma.CumulativeSeriesTerm.MezoHoffman2017 (
  170.                     org.drip.specialfunction.digamma.SaddlePoints.LeadingRoots (
  171.                         saddlePointFunction,
  172.                         saddlePointCount
  173.                     )
  174.                 ),
  175.                 false,
  176.                 termWeightMap
  177.             );
  178.         }
  179.         catch (java.lang.Exception e)
  180.         {
  181.             e.printStackTrace();
  182.         }

  183.         return null;
  184.     }

  185.     /**
  186.      * Construct the R<sup>1</sup> To R<sup>1</sup> Gauss Cumulative Series
  187.      *
  188.      * @param termCount Count of the Number of Terms
  189.      *
  190.      * @return The R<sup>1</sup> To R<sup>1</sup> Gauss Cumulative Series
  191.      */

  192.     public static final org.drip.numerical.estimation.R1ToR1Series Gauss (
  193.         final int termCount)
  194.     {
  195.         int seriesCount = (termCount - 1) / 2;

  196.         try
  197.         {
  198.             java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  199.                 java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  200.             for (int termIndex = 1; termIndex <= seriesCount; ++termIndex)
  201.             {
  202.                 termWeightMap.put (
  203.                     termIndex,
  204.                     1.
  205.                 );
  206.             }

  207.             return new org.drip.numerical.estimation.R1ToR1Series (
  208.                 org.drip.specialfunction.digamma.CumulativeSeriesTerm.Gauss (termCount),
  209.                 false,
  210.                 termWeightMap
  211.             );
  212.         }
  213.         catch (java.lang.Exception e)
  214.         {
  215.             e.printStackTrace();
  216.         }

  217.         return null;
  218.     }

  219.     /**
  220.      * Construct the R<sup>1</sup> To R<sup>1</sup> Asymptotic Cumulative Series
  221.      *
  222.      * @return The R<sup>1</sup> To R<sup>1</sup> Asymptotic Cumulative Series
  223.      */

  224.     public static final org.drip.numerical.estimation.R1ToR1Series Asymptotic()
  225.     {
  226.         try
  227.         {
  228.             java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  229.                 java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  230.             termWeightMap.put (
  231.                 1,
  232.                 -1. / 12.
  233.             );

  234.             termWeightMap.put (
  235.                 2,
  236.                 1. / 120.
  237.             );

  238.             termWeightMap.put (
  239.                 3,
  240.                 -1. / 252.
  241.             );

  242.             termWeightMap.put (
  243.                 4,
  244.                 1. / 240.
  245.             );

  246.             termWeightMap.put (
  247.                 5,
  248.                 -1. / 132.
  249.             );

  250.             termWeightMap.put (
  251.                 6,
  252.                 691. / 32760.
  253.             );

  254.             termWeightMap.put (
  255.                 7,
  256.                 -1. / 12.
  257.             );

  258.             return new org.drip.numerical.estimation.R1ToR1Series (
  259.                 org.drip.specialfunction.digamma.CumulativeSeriesTerm.Asymptotic(),
  260.                 false,
  261.                 termWeightMap
  262.             );
  263.         }
  264.         catch (java.lang.Exception e)
  265.         {
  266.             e.printStackTrace();
  267.         }

  268.         return null;
  269.     }

  270.     /**
  271.      * Construct the R<sup>1</sup> To R<sup>1</sup> Exponential Asymptotic Cumulative Series
  272.      *
  273.      * @return The R<sup>1</sup> To R<sup>1</sup> Exponential Asymptotic Cumulative Series
  274.      */

  275.     public static final org.drip.numerical.estimation.R1ToR1Series ExponentialAsymptote()
  276.     {
  277.         try
  278.         {
  279.             java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  280.                 java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  281.             termWeightMap.put (
  282.                 1,
  283.                 1.
  284.             );

  285.             termWeightMap.put (
  286.                 2,
  287.                 1. / 2.
  288.             );

  289.             termWeightMap.put (
  290.                 3,
  291.                 5. / 24.
  292.             );

  293.             termWeightMap.put (
  294.                 4,
  295.                 1. / 16.
  296.             );

  297.             termWeightMap.put (
  298.                 5,
  299.                 47. / (48. * 120.)
  300.             );

  301.             termWeightMap.put (
  302.                 6,
  303.                 1. / (16. * 144.)
  304.             );

  305.             return new org.drip.numerical.estimation.R1ToR1Series (
  306.                 org.drip.specialfunction.digamma.CumulativeSeriesTerm.ExponentialAsymptote(),
  307.                 false,
  308.                 termWeightMap
  309.             );
  310.         }
  311.         catch (java.lang.Exception e)
  312.         {
  313.             e.printStackTrace();
  314.         }

  315.         return null;
  316.     }

  317.     /**
  318.      * Construct the R<sup>1</sup> To R<sup>1</sup> Exponential Half-Shifted Asymptotic Cumulative Series
  319.      *
  320.      * @return The R<sup>1</sup> To R<sup>1</sup> Exponential Half-Shifted Asymptotic Cumulative Series
  321.      */

  322.     public static final org.drip.numerical.estimation.R1ToR1Series ExponentialAsymptoteHalfShifted()
  323.     {
  324.         try
  325.         {
  326.             java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  327.                 java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  328.             termWeightMap.put (
  329.                 1,
  330.                 1. / org.drip.numerical.common.NumberUtil.Factorial (4)
  331.             );

  332.             termWeightMap.put (
  333.                 2,
  334.                 -37. / (8. * org.drip.numerical.common.NumberUtil.Factorial (6))
  335.             );

  336.             termWeightMap.put (
  337.                 3,
  338.                 10313. / (72. * org.drip.numerical.common.NumberUtil.Factorial (8))
  339.             );

  340.             termWeightMap.put (
  341.                 4,
  342.                 -5509121. / (384. * org.drip.numerical.common.NumberUtil.Factorial (10))
  343.             );

  344.             termWeightMap.put (
  345.                 5,
  346.                 47. / (48. * 120.)
  347.             );

  348.             termWeightMap.put (
  349.                 6,
  350.                 1. / (16. * 144.)
  351.             );

  352.             return new org.drip.numerical.estimation.R1ToR1Series (
  353.                 org.drip.specialfunction.digamma.CumulativeSeriesTerm.ExponentialAsymptoteHalfShifted(),
  354.                 false,
  355.                 termWeightMap
  356.             );
  357.         }
  358.         catch (java.lang.Exception e)
  359.         {
  360.             e.printStackTrace();
  361.         }

  362.         return null;
  363.     }

  364.     /**
  365.      * Construct the R<sup>1</sup> To R<sup>1</sup> Taylor Riemann-Zeta Cumulative Series
  366.      *
  367.      * @param riemannZetaEstimator The Riemann-Zeta Estimator
  368.      * @param termCount Count of the Number of Terms
  369.      *
  370.      * @return The R<sup>1</sup> To R<sup>1</sup> Taylor Riemann-Zeta Cumulative Series
  371.      */

  372.     public static final org.drip.numerical.estimation.R1ToR1Series TaylorRiemannZeta (
  373.         final org.drip.function.definition.R1ToR1 riemannZetaEstimator,
  374.         final int termCount)
  375.     {
  376.         try
  377.         {
  378.             java.util.TreeMap<java.lang.Integer, java.lang.Double> termWeightMap = new
  379.                 java.util.TreeMap<java.lang.Integer, java.lang.Double>();

  380.             for (int termIndex = 1; termIndex <= termCount; ++termIndex)
  381.             {
  382.                 termWeightMap.put (
  383.                     termIndex,
  384.                     1.
  385.                 );
  386.             }

  387.             return new org.drip.numerical.estimation.R1ToR1Series (
  388.                 org.drip.specialfunction.digamma.CumulativeSeriesTerm.TaylorRiemannZeta
  389.                     (riemannZetaEstimator),
  390.                 false,
  391.                 termWeightMap
  392.             );
  393.         }
  394.         catch (java.lang.Exception e)
  395.         {
  396.             e.printStackTrace();
  397.         }

  398.         return null;
  399.     }
  400. }