KohlrauschMomentEstimate.java

  1. package org.drip.sample.scaledexponential;

  2. import org.drip.function.definition.R1ToR1;
  3. import org.drip.numerical.common.FormatUtil;
  4. import org.drip.service.env.EnvManager;
  5. import org.drip.specialfunction.definition.ScaledExponentialEstimator;
  6. import org.drip.specialfunction.gamma.WindschitlTothAnalytic;

  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>KohlrauschMomentEstimate</i> illustrates the Estimation of the Moments of the Kohlrausch Function. The
  69.  * References are:
  70.  *
  71.  * <br><br>
  72.  *  <ul>
  73.  *      <li>
  74.  *          Gradshteyn, I. S., I. M. Ryzhik, Y. V. Geronimus, M. Y. Tseytlin, and A. Jeffrey (2015):
  75.  *              <i>Tables of Integrals, Series, and Products</i> <b>Academic Press</b>
  76.  *      </li>
  77.  *      <li>
  78.  *          Hilfer, J. (2002): H-function Representations for Stretched Exponential Relaxation and non-Debye
  79.  *              Susceptibilities in Glassy Systems <i>Physical Review E</i> <b>65 (6)</b> 061510
  80.  *      </li>
  81.  *      <li>
  82.  *          Wikipedia (2019): Stretched Exponential Function
  83.  *              https://en.wikipedia.org/wiki/Stretched_exponential_function
  84.  *      </li>
  85.  *      <li>
  86.  *          Wuttke, J. (2012): Laplace-Fourier Transform of the Stretched Exponential Function: Analytic
  87.  *              Error-Bounds, Double Exponential Transform, and Open Source Implementation <i>libkw</i>
  88.  *              <i>Algorithm</i> <b>5 (4)</b> 604-628
  89.  *      </li>
  90.  *      <li>
  91.  *          Zorn, R. (2002): Logarithmic Moments of Relaxation Time Distributions <i>Journal of Chemical
  92.  *              Physics</i> <b>116 (8)</b> 3204-3209
  93.  *      </li>
  94.  *  </ul>
  95.  *
  96.  *  <br><br>
  97.  *  <ul>
  98.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalCore.md">Numerical Core Module</a></li>
  99.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalOptimizerLibrary.md">Numerical Optimizer</a></li>
  100.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/specialfunction/README.md">Special Function Project</a></li>
  101.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/specialfunction/ode/README.md">Special Function Ordinary Differential Equations</a></li>
  102.  *  </ul>
  103.  *
  104.  * @author Lakshmi Krishnamurthy
  105.  */

  106. public class KohlrauschMomentEstimate
  107. {

  108.     public static final void main (
  109.         final String[] argumentArray)
  110.         throws Exception
  111.     {
  112.         EnvManager.InitEnv ("");

  113.         double[] betaArray =
  114.         {
  115.              0.1,
  116.              0.2,
  117.              0.3,
  118.              0.4,
  119.              0.5,
  120.              0.6,
  121.              0.7,
  122.              0.8,
  123.              0.9,
  124.              1.0,
  125.              1.2,
  126.              1.4,
  127.              1.6,
  128.              1.8,
  129.              2.0,
  130.              2.5,
  131.              3.0,
  132.              3.5,
  133.              4.0,
  134.              4.5,
  135.              5.0,
  136.         };
  137.         int[] momentArray =
  138.         {
  139.             1,
  140.             2,
  141.             3,
  142.         };

  143.         R1ToR1 gammaEstimator = new WindschitlTothAnalytic (null);

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

  145.         System.out.println ("\t|         KOHLRAUSCH MOMENT ESTIMATOR         ||");

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

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

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

  149.         System.out.println ("\t|            - Moment Value                   ||");

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

  151.         for (double beta : betaArray)
  152.         {
  153.             ScaledExponentialEstimator scaledExponentialEstimator = new ScaledExponentialEstimator (
  154.                 beta,
  155.                 1.
  156.             );

  157.             String display = "\t| [" + FormatUtil.FormatDouble (beta, 1, 1, 1., false) + "] => ";

  158.             for (int moment : momentArray)
  159.             {
  160.                 display = display + " " + FormatUtil.FormatDouble (
  161.                     scaledExponentialEstimator.higherMoment (
  162.                         moment,
  163.                         gammaEstimator
  164.                     ), 2, 6, 1., false
  165.                 ) + " |";
  166.             }

  167.             System.out.println (display + "|");
  168.         }

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

  170.         EnvManager.TerminateEnv();
  171.     }
  172. }