BrownianPopulationCentralMeasures.java

  1. package org.drip.sample.ckls;

  2. import org.drip.dynamics.meanreverting.R1BrownianStochasticEvolver;
  3. import org.drip.dynamics.process.R1StochasticEvolver;
  4. import org.drip.measure.statistics.PopulationCentralMeasures;
  5. import org.drip.numerical.common.FormatUtil;
  6. import org.drip.service.env.EnvManager;

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

  10. /*!
  11.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  12.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  13.  *
  14.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  15.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  16.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  17.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  18.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  19.  *      and computational support.
  20.  *  
  21.  *      https://lakshmidrip.github.io/DROP/
  22.  *  
  23.  *  DROP is composed of three modules:
  24.  *  
  25.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  26.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  27.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  28.  *
  29.  *  DROP Product Core implements libraries for the following:
  30.  *  - Fixed Income Analytics
  31.  *  - Loan Analytics
  32.  *  - Transaction Cost Analytics
  33.  *
  34.  *  DROP Portfolio Core implements libraries for the following:
  35.  *  - Asset Allocation Analytics
  36.  *  - Asset Liability Management Analytics
  37.  *  - Capital Estimation Analytics
  38.  *  - Exposure Analytics
  39.  *  - Margin Analytics
  40.  *  - XVA Analytics
  41.  *
  42.  *  DROP Computational Core implements libraries for the following:
  43.  *  - Algorithm Support
  44.  *  - Computation Support
  45.  *  - Function Analysis
  46.  *  - Model Validation
  47.  *  - Numerical Analysis
  48.  *  - Numerical Optimizer
  49.  *  - Spline Builder
  50.  *  - Statistical Learning
  51.  *
  52.  *  Documentation for DROP is Spread Over:
  53.  *
  54.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  55.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  56.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  57.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  58.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  59.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  60.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  61.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  62.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  63.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  64.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  65.  *
  66.  *  Licensed under the Apache License, Version 2.0 (the "License");
  67.  *      you may not use this file except in compliance with the License.
  68.  *  
  69.  *  You may obtain a copy of the License at
  70.  *      http://www.apache.org/licenses/LICENSE-2.0
  71.  *  
  72.  *  Unless required by applicable law or agreed to in writing, software
  73.  *      distributed under the License is distributed on an "AS IS" BASIS,
  74.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  75.  *  
  76.  *  See the License for the specific language governing permissions and
  77.  *      limitations under the License.
  78.  */

  79. /**
  80.  * <i>BrownianPopulationCentralMeasures</i> illustrates the Aging of Population Central Measures, both
  81.  *  Temporal and Steady-State, of an Evolving R<sup>1</sup> Brownian Process. The References are:
  82.  *  
  83.  *  <br><br>
  84.  *  <ul>
  85.  *      <li>
  86.  *          Bogoliubov, N. N., and D. P. Sankevich (1994): N. N. Bogoliubov and Statistical Mechanics
  87.  *              <i>Russian Mathematical Surveys</i> <b>49 (5)</b> 19-49
  88.  *      </li>
  89.  *      <li>
  90.  *          Holubec, V., K. Kroy, and S. Steffenoni (2019): Physically Consistent Numerical Solver for
  91.  *              Time-dependent Fokker-Planck Equations <i>Physical Review E</i> <b>99 (4)</b> 032117
  92.  *      </li>
  93.  *      <li>
  94.  *          Kadanoff, L. P. (2000): <i>Statistical Physics: Statics, Dynamics, and Re-normalization</i>
  95.  *              <b>World Scientific</b>
  96.  *      </li>
  97.  *      <li>
  98.  *          Ottinger, H. C. (1996): <i>Stochastic Processes in Polymeric Fluids</i> <b>Springer-Verlag</b>
  99.  *              Berlin-Heidelberg
  100.  *      </li>
  101.  *      <li>
  102.  *          Wikipedia (2019): Fokker-Planck Equation
  103.  *              https://en.wikipedia.org/wiki/Fokker%E2%80%93Planck_equation
  104.  *      </li>
  105.  *  </ul>
  106.  *
  107.  *  <br><br>
  108.  *  <ul>
  109.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  110.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  111.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">DROP API Construction and Usage</a></li>
  112.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/ckls/README.md">Analysis of CKLS Process Variants</a></li>
  113.  *  </ul>
  114.  *
  115.  * @author Lakshmi Krishnamurthy
  116.  */

  117. public class BrownianPopulationCentralMeasures
  118. {

  119.     public static final void main (
  120.         final String[] argumentArray)
  121.         throws Exception
  122.     {
  123.         EnvManager.InitEnv (
  124.             ""
  125.         );
  126.         double[] tArray =
  127.         {
  128.              1.0,
  129.              2.0,
  130.              3.0,
  131.              4.0,
  132.              5.0,
  133.              6.0,
  134.              7.0,
  135.         };

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

  137.         System.out.println ("\t|                                               BROWNIAN FOKKER-PLANCK PDF TEMPORAL CENTRAL MEASURES                                                ||");

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

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

  140.         System.out.println ("\t|                - Row of PDF {Mean | Variance} Tuple over t                                                                                        ||");

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

  142.         R1StochasticEvolver r1StochasticEvolver = R1BrownianStochasticEvolver.Wiener (
  143.             0.01
  144.         );

  145.         java.lang.String dump = "\t|";

  146.         for (double t : tArray)
  147.         {
  148.             PopulationCentralMeasures populationCentralMeasures =
  149.                 r1StochasticEvolver.temporalPopulationCentralMeasures (
  150.                     0.,
  151.                     t
  152.                 );

  153.             dump = dump + " {" + FormatUtil.FormatDouble (
  154.                 populationCentralMeasures.mean(), 1, 4, 1.
  155.             ) + " |" + FormatUtil.FormatDouble (
  156.                 populationCentralMeasures.variance(), 1, 4, 1.
  157.             ) + "}";
  158.         }

  159.         System.out.println (dump);

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

  161.         System.out.println();

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

  163.         System.out.println ("\t|                                             BROWNIAN FOKKER-PLANCK PDF STEADY STATE CENTRAL MEASURES                                              ||");

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

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

  166.         System.out.println ("\t|                - PDF {Mean | Variance} Tuple                                                                                                      ||");

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

  168.         PopulationCentralMeasures populationCentralMeasures =
  169.             r1StochasticEvolver.steadyStatePopulationCentralMeasures (
  170.                 0.
  171.             );

  172.         System.out.println (
  173.             "\t| {" + FormatUtil.FormatDouble (
  174.                 populationCentralMeasures.mean(), 1, 4, 1.
  175.             ) + " |" + FormatUtil.FormatDouble (
  176.                 populationCentralMeasures.variance(), 1, 4, 1.
  177.             ) + "}"
  178.         );

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

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