UnitScaleMaxwell.java

  1. package org.drip.sample.randomdiscrete;

  2. import org.drip.measure.discrete.SequenceGenerator;
  3. import org.drip.numerical.common.FormatUtil;
  4. import org.drip.service.env.EnvManager;

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

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

  65. /**
  66.  * <i>UnitScaleMaxwell</i> demonstrates Generation of Unit Scale Maxwell R<sup>1</sup> Random Numbers.
  67.  *
  68.  * <br><br>
  69.  *  <ul>
  70.  *      <li>
  71.  *          Backstrom, T., and J. Fischer (2018): Fast Randomization for Distributed Low Bit-rate Coding of
  72.  *              Speech and Audio <i>IEEE/ACM Transactions on Audio, Speech, and Language Processing</i> <b>26
  73.  *              (1)</b> 19-30
  74.  *      </li>
  75.  *      <li>
  76.  *          Chi-Squared Distribution (2019): Chi-Squared Function
  77.  *              https://en.wikipedia.org/wiki/Chi-squared_distribution
  78.  *      </li>
  79.  *      <li>
  80.  *          Johnson, N. L., S. Klotz, and N. Balakrishnan (1994): <i>Continuous Univariate Distributions
  81.  *              <b>1</b> 2<sup>nd</sup> Edition</i> <b>John Wiley and Sons</b>
  82.  *      </li>
  83.  *      <li>
  84.  *          Lancaster, H, O. (1969): <i>The Chi-Squared Distribution</i> <b>Wiley</b>
  85.  *      </li>
  86.  *      <li>
  87.  *          Pillai, N. S. (1026): An Unexpected Encounter with Cauchy and Levy <i>Annals of Statistics</i>
  88.  *              <b>44 (5)</b> 2089-2097
  89.  *      </li>
  90.  *  </ul>
  91.  *
  92.  *  <br><br>
  93.  *  <ul>
  94.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalCore.md">Numerical Core Module</a></li>
  95.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalOptimizerLibrary.md">Numerical Optimizer Library</a></li>
  96.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/measure">Measure</a></li>
  97.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/measure/discrete">Discrete</a></li>
  98.  *  </ul>
  99.  *
  100.  * @author Lakshmi Krishnamurthy
  101.  */

  102. public class UnitScaleMaxwell
  103. {

  104.     private static final void DisplayStream()
  105.         throws Exception
  106.     {
  107.         double[] randomArray = SequenceGenerator.UnitScaleMaxwell (200);

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

  109.         for (int row = 0; row < 20; ++row)
  110.         {
  111.             String rowDump = "\t|";

  112.             for (int column = 0; column < 10; ++column)
  113.             {
  114.                 rowDump = rowDump + FormatUtil.FormatDouble (
  115.                     randomArray[row * 10 + column], 2, 4, 1.
  116.                 ) + " |";
  117.             }

  118.             System.out.println (rowDump + "|");
  119.         }

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

  121.         System.out.println();
  122.     }

  123.     public static final void main (
  124.         final String[] argumentArray)
  125.         throws Exception
  126.     {
  127.         EnvManager.InitEnv ("");

  128.         DisplayStream();

  129.         EnvManager.TerminateEnv();
  130.     }
  131. }