GaussDougallProperty.java

  1. package org.drip.sample.hypergeometric;

  2. import org.drip.function.definition.R1PropertyVerification;
  3. import org.drip.function.definition.R3ToR1Property;
  4. import org.drip.numerical.common.FormatUtil;
  5. import org.drip.service.env.EnvManager;
  6. import org.drip.specialfunction.property.HypergeometricEqualityLemma;

  7. /*
  8.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  9.  */

  10. /*!
  11.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  12.  *
  13.  *  This file is part of DROP, an open-source library targeting risk, transaction costs, exposure, margin
  14.  *      calculations, and portfolio construction within and across fixed income, credit, commodity, equity,
  15.  *      FX, and structured products.
  16.  *  
  17.  *      https://lakshmidrip.github.io/DROP/
  18.  *  
  19.  *  DROP is composed of three main modules:
  20.  *  
  21.  *  - DROP Analytics Core - https://lakshmidrip.github.io/DROP-Analytics-Core/
  22.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  23.  *  - DROP Numerical Core - https://lakshmidrip.github.io/DROP-Numerical-Core/
  24.  *
  25.  *  DROP Analytics Core implements libraries for the following:
  26.  *  - Fixed Income Analytics
  27.  *  - Asset Backed Analytics
  28.  *  - XVA Analytics
  29.  *  - Exposure and Margin Analytics
  30.  *
  31.  *  DROP Portfolio Core implements libraries for the following:
  32.  *  - Asset Allocation Analytics
  33.  *  - Transaction Cost Analytics
  34.  *
  35.  *  DROP Numerical Core implements libraries for the following:
  36.  *  - Statistical Learning Library
  37.  *  - Numerical Optimizer Library
  38.  *  - Machine Learning Library
  39.  *  - Spline Builder Library
  40.  *
  41.  *  Documentation for DROP is Spread Over:
  42.  *
  43.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  44.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  45.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  46.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  47.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  48.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  49.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  50.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  51.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  52.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  53.  *
  54.  *  Licensed under the Apache License, Version 2.0 (the "License");
  55.  *      you may not use this file except in compliance with the License.
  56.  *  
  57.  *  You may obtain a copy of the License at
  58.  *      http://www.apache.org/licenses/LICENSE-2.0
  59.  *  
  60.  *  Unless required by applicable law or agreed to in writing, software
  61.  *      distributed under the License is distributed on an "AS IS" BASIS,
  62.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  63.  *  
  64.  *  See the License for the specific language governing permissions and
  65.  *      limitations under the License.
  66.  */

  67. /**
  68.  * <i>GaussDougallProperty</i> verifies the Gauss Dougall Identity Property Lemma for z = 1. The References
  69.  * are:
  70.  *
  71.  * <br><br>
  72.  *  <ul>
  73.  *      <li>
  74.  *          Gessel, I., and D. Stanton (1982): Strange Evaluations of Hyper-geometric Series <i>SIAM Journal
  75.  *              on Mathematical Analysis</i> <b>13 (2)</b> 295-308
  76.  *      </li>
  77.  *      <li>
  78.  *          Koepf, W (1995): Algorithms for m-fold Hyper-geometric Summation <i>Journal of Symbolic
  79.  *              Computation</i> <b>20 (4)</b> 399-417
  80.  *      </li>
  81.  *      <li>
  82.  *          Lavoie, J. L., F. Grondin, and A. K. Rathie (1996): Generalization of Whipple’s Theorem on the
  83.  *              Sum of a (_2^3)F(a,b;c;z) <i>Journal of Computational and Applied Mathematics</i> <b>72</b>
  84.  *              293-300
  85.  *      </li>
  86.  *      <li>
  87.  *          National Institute of Standards and Technology (2019): Hyper-geometric Function
  88.  *              https://dlmf.nist.gov/15
  89.  *      </li>
  90.  *      <li>
  91.  *          Wikipedia (2019): Hyper-geometric Function https://en.wikipedia.org/wiki/Hypergeometric_function
  92.  *      </li>
  93.  *  </ul>
  94.  *
  95.  *  <br><br>
  96.  *  <ul>
  97.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalCore.md">Numerical Core Module</a></li>
  98.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalOptimizerLibrary.md">Numerical Optimizer</a></li>
  99.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Function</a></li>
  100.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/hypergeometric/README.md">Estimates of Hyper-geometric Function</a></li>
  101.  *  </ul>
  102.  *
  103.  * @author Lakshmi Krishnamurthy
  104.  */

  105. public class GaussDougallProperty
  106. {

  107.     private static final void Verifier (
  108.         final int m,
  109.         final double b,
  110.         final double c,
  111.         final R3ToR1Property gaussDougallProperty)
  112.         throws Exception
  113.     {
  114.         R1PropertyVerification propertyVerification = gaussDougallProperty.verify (
  115.             m,
  116.             b,
  117.             c
  118.         );

  119.         System.out.println (
  120.             "\t| {" + FormatUtil.FormatDouble (m, 1, 2, 1., false) + ", " +
  121.                 FormatUtil.FormatDouble (b, 1, 2, 1., false) + ", " +
  122.                 FormatUtil.FormatDouble (c, 1, 2, 1., false) + "} => " +
  123.                 FormatUtil.FormatDouble (propertyVerification.lValue(), 1, 10, 1.) + " | " +
  124.                 FormatUtil.FormatDouble (propertyVerification.rValue(), 1, 10, 1.) + " | " +
  125.                 propertyVerification.verified() + " ||"
  126.         );
  127.     }

  128.     public static final void main (
  129.         final String[] argumentArray)
  130.         throws Exception
  131.     {
  132.         EnvManager.InitEnv ("");

  133.         int[] mArray =
  134.         {
  135.             1,
  136.             2,
  137.             3,
  138.             4,
  139.         };
  140.         double[] bArray =
  141.         {
  142.             0.5,
  143.             1.0,
  144.             1.5,
  145.             2.0,
  146.         };
  147.         double[] cArray =
  148.         {
  149.             5.,
  150.             6.,
  151.         };

  152.         R3ToR1Property gaussDougallProperty = HypergeometricEqualityLemma.GaussDougallZPlusOne();

  153.         System.out.println ("\t|------------------------------------------------------------||");

  154.         System.out.println ("\t|              GAUSS DOUGALL PROPERTY VERIFIER               ||");

  155.         System.out.println ("\t|------------------------------------------------------------||");

  156.         System.out.println ("\t|        L -> R:                                             ||");

  157.         System.out.println ("\t|                - a                                         ||");

  158.         System.out.println ("\t|                - b                                         ||");

  159.         System.out.println ("\t|                - c                                         ||");

  160.         System.out.println ("\t|                - LHS                                       ||");

  161.         System.out.println ("\t|                - RHS                                       ||");

  162.         System.out.println ("\t|                - Verified?                                 ||");

  163.         System.out.println ("\t|------------------------------------------------------------||");

  164.         for (int m : mArray)
  165.         {
  166.             for (double b : bArray)
  167.             {
  168.                 for (double c : cArray)
  169.                 {
  170.                     Verifier (
  171.                         m,
  172.                         b,
  173.                         c,
  174.                         gaussDougallProperty
  175.                     );
  176.                 }
  177.             }
  178.         }

  179.         System.out.println ("\t|------------------------------------------------------------||");

  180.         EnvManager.TerminateEnv();
  181.     }
  182. }