MRG32k3a.java

  1. package org.drip.sample.rng;

  2. import org.drip.measure.crng.MultipleRecursiveGeneratorLEcuyer;
  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) 2018 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  11.  *
  12.  *  This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model
  13.  *      libraries targeting analysts and developers
  14.  *      https://lakshmidrip.github.io/DRIP/
  15.  *  
  16.  *  DRIP is composed of four main libraries:
  17.  *  
  18.  *  - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/
  19.  *  - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/
  20.  *  - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/
  21.  *  - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/
  22.  *
  23.  *  - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options,
  24.  *      Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA
  25.  *      Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV
  26.  *      Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM
  27.  *      Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics.
  28.  *
  29.  *  - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy
  30.  *      Incorporator, Holdings Constraint, and Transaction Costs.
  31.  *
  32.  *  - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality.
  33.  *
  34.  *  - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning.
  35.  *
  36.  *  Licensed under the Apache License, Version 2.0 (the "License");
  37.  *      you may not use this file except in compliance with the License.
  38.  *  
  39.  *  You may obtain a copy of the License at
  40.  *      http://www.apache.org/licenses/LICENSE-2.0
  41.  *  
  42.  *  Unless required by applicable law or agreed to in writing, software
  43.  *      distributed under the License is distributed on an "AS IS" BASIS,
  44.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  45.  *  
  46.  *  See the License for the specific language governing permissions and
  47.  *      limitations under the License.
  48.  */

  49. /**
  50.  * MRG32k3a demonstrates the Construction and Invocation of MRG32k3a Variant of the L'Ecuyer's Multiple
  51.  *  Recursive Generator.
  52.  *
  53.  * @author Lakshmi Krishnamurthy
  54.  */

  55. public class MRG32k3a {

  56.     public static final void main (
  57.         final String[] astrArgs)
  58.         throws Exception
  59.     {
  60.         EnvManager.InitEnv ("");

  61.         int iRow = 50;
  62.         int iColumn = 15;

  63.         MultipleRecursiveGeneratorLEcuyer mrgl = MultipleRecursiveGeneratorLEcuyer.MRG32k3a();

  64.         System.out.println();

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

  66.         for (int i = 0; i < iRow; ++i) {
  67.             String strDump = "\t||";

  68.             for (int j = 0; j < iColumn; ++j)
  69.                 strDump = strDump + FormatUtil.FormatDouble (mrgl.next(), 11, 0, 1.) + " |";

  70.             System.out.println (strDump + "|");
  71.         }

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

  73.         System.out.println();
  74.     }
  75. }