ExponentialConvexProperty.java

  1. package org.drip.sample.gamma;

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

  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>ExponentialConvexProperty</i> demonstrates the Verification of the Exponential Convex Property of the
  69.  * Gamma Function. The References are:
  70.  *
  71.  * <br><br>
  72.  *  <ul>
  73.  *      <li>
  74.  *          Blagouchine, I. V. (2014): Re-discovery of Malmsten's Integrals, their Evaluation by Contour
  75.  *              Integration Methods, and some Related Results <i>Ramanujan Journal</i> <b>35 (1)</b> 21-110
  76.  *      </li>
  77.  *      <li>
  78.  *          Borwein, J. M., and R. M. Corless (2017): Gamma Function and the Factorial in the Monthly
  79.  *              https://arxiv.org/abs/1703.05349 <b>arXiv</b>
  80.  *      </li>
  81.  *      <li>
  82.  *          Davis, P. J. (1959): Leonhard Euler's Integral: A Historical Profile of the Gamma Function
  83.  *              <i>American Mathematical Monthly</i> <b>66 (10)</b> 849-869
  84.  *      </li>
  85.  *      <li>
  86.  *          Whitaker, E. T., and G. N. Watson (1996): <i>A Course on Modern Analysis</i> <b>Cambridge
  87.  *              University Press</b> New York
  88.  *      </li>
  89.  *      <li>
  90.  *          Wikipedia (2019): Gamma Function https://en.wikipedia.org/wiki/Gamma_function
  91.  *      </li>
  92.  *  </ul>
  93.  *
  94.  *  <br><br>
  95.  *  <ul>
  96.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalCore.md">Numerical Core Module</a></li>
  97.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalOptimizerLibrary.md">Numerical Optimizer</a></li>
  98.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Function</a></li>
  99.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/gamma/README.md">Integrand Estimates of Gamma Functions</a></li>
  100.  *  </ul>
  101.  *
  102.  * @author Lakshmi Krishnamurthy
  103.  */

  104. public class ExponentialConvexProperty
  105. {

  106.     private static final void Verifier (
  107.         final double z1,
  108.         final double z2,
  109.         final double[] tArray)
  110.         throws Exception
  111.     {
  112.         System.out.println ("\t|---------------------------------------------------||");

  113.         System.out.println ("\t|    GAMMA FUNCTION EXPONENTIAL CONVEX PROPERTY     ||");

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

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

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

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

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

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

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

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

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

  123.         R1ToR1Property exponentiallyConvexProperty = GammaInequalityLemma.ExponentiallyConvex (
  124.             z1,
  125.             z2
  126.         );

  127.         for (double t : tArray)
  128.         {
  129.             R1PropertyVerification propertyVerification = exponentiallyConvexProperty.verify (t);

  130.             System.out.println (
  131.                 "\t|" + FormatUtil.FormatDouble (t, 2, 2, 1.) + " => " +
  132.                     FormatUtil.FormatDouble (propertyVerification.lValue(), 3, 10, 1.) + " | " +
  133.                     FormatUtil.FormatDouble (propertyVerification.rValue(), 3, 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[] z1Array =
  146.         {
  147.              1.0,
  148.              4.0,
  149.              7.0,
  150.             10.0
  151.         };
  152.         double[] z2Array =
  153.         {
  154.             0.5,
  155.             3.5,
  156.             6.5,
  157.             9.5,
  158.         };
  159.         double[] tArray =
  160.         {
  161.             0.0,
  162.             0.1,
  163.             0.2,
  164.             0.3,
  165.             0.4,
  166.             0.5,
  167.             0.6,
  168.             0.7,
  169.             0.8,
  170.             0.9,
  171.             1.0,
  172.         };

  173.         for (double z1 : z1Array)
  174.         {
  175.             for (double z2 : z2Array)
  176.             {
  177.                 Verifier (
  178.                     z1,
  179.                     z2,
  180.                     tArray
  181.                 );
  182.             }
  183.         }

  184.         EnvManager.TerminateEnv();
  185.     }
  186. }