GaussContiguousProperty4.java

  1. package org.drip.sample.hypergeometric;

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

  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>GaussContiguousProperty4</i> verifies the Gauss Contiguous Identity #4 Lemma for Hyper-geometric
  69.  * Functions. The References 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 GaussContiguousProperty4
  106. {

  107.     private static final void Verifier (
  108.         final double a,
  109.         final double b,
  110.         final double c,
  111.         final double[] zArray,
  112.         final R1ToR1Property gaussContiguousProperty4)
  113.         throws Exception
  114.     {
  115.         System.out.println ("\t|----------------------------------------------||");

  116.         System.out.println ("\t|        GAUSS CONTIGUOUS PROPERTY #4          ||");

  117.         System.out.println ("\t|                  a = " + FormatUtil.FormatDouble (a, 1, 1, 1.));

  118.         System.out.println ("\t|                  b = " + FormatUtil.FormatDouble (b, 1, 1, 1.));

  119.         System.out.println ("\t|                  c = " + FormatUtil.FormatDouble (c, 1, 1, 1.));

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

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

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

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

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

  125.         System.out.println ("\t|                - Verification Success?       ||");

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

  127.         for (double z : zArray)
  128.         {
  129.             R1PropertyVerification propertyVerification = gaussContiguousProperty4.verify (z);

  130.             System.out.println (
  131.                 "\t|" + FormatUtil.FormatDouble (z, 1, 2, 1.) + " => " +
  132.                     FormatUtil.FormatDouble (propertyVerification.lValue(), 1, 10, 1.) + " | " +
  133.                     FormatUtil.FormatDouble (propertyVerification.rValue(), 1, 10, 1.) + " | " +
  134.                     propertyVerification.verified() + " ||"
  135.             );
  136.         }

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

  138.         System.out.println();
  139.     }

  140.     public static final void main (
  141.         final String[] argumentArray)
  142.         throws Exception
  143.     {
  144.         EnvManager.InitEnv ("");

  145.         double[] aArray =
  146.         {
  147.             1.,
  148.             2.,
  149.             3.,
  150.             4.,
  151.             5.,
  152.         };
  153.         double[] bArray =
  154.         {
  155.             3.,
  156.             4.,
  157.         };
  158.         double[] cArray =
  159.         {
  160.             5.,
  161.             6.,
  162.         };
  163.         double[] zArray =
  164.         {
  165.             -0.80,
  166.             -0.60,
  167.             -0.40,
  168.             -0.20,
  169.              0.00,
  170.              0.20,
  171.              0.40,
  172.              0.60,
  173.              0.80
  174.         };

  175.         for (double a : aArray)
  176.         {
  177.             for (double b : bArray)
  178.             {
  179.                 for (double c : cArray)
  180.                 {
  181.                     Verifier (
  182.                         a,
  183.                         b,
  184.                         c,
  185.                         zArray,
  186.                         GaussContiguousEqualityLemma.RelationIdentity4 (
  187.                             a,
  188.                             b,
  189.                             c
  190.                         )
  191.                     );
  192.                 }
  193.             }
  194.         }

  195.         EnvManager.TerminateEnv();
  196.     }
  197. }