DiagonalScalingOperator.java

  1. package org.drip.learning.kernel;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

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

  78. /**
  79.  * <i>DiagonalScalingOperator</i> implements the Scaling Operator that is used to determine the Bounds of the
  80.  * R<sup>x</sup> L<sub>2</sub> To R<sup>x</sup> L<sub>2</sub> Kernel Linear Integral Operator defined by:
  81.  *
  82.  *      T_k [f(.)] := Integral Over Input Space {k (., y) * f(y) * d[Prob(y)]}
  83.  *  
  84.  * <br><br>
  85.  *  The References are:
  86.  * <br><br>
  87.  * <ul>
  88.  *  <li>
  89.  *      Ash, R. (1965): <i>Information Theory</i> <b>Inter-science</b> New York
  90.  *  </li>
  91.  *  <li>
  92.  *      Carl, B., and I. Stephani (1990): <i>Entropy, Compactness, and Approximation of Operators</i>
  93.  *          <b>Cambridge University Press</b> Cambridge UK
  94.  *  </li>
  95.  *  <li>
  96.  *      Gordon, Y., H. Konig, and C. Schutt (1987): Geometric and Probabilistic Estimates of Entropy and
  97.  *          Approximation Numbers of Operators <i>Journal of Approximation Theory</i> <b>49</b> 219-237
  98.  *  </li>
  99.  *  <li>
  100.  *      Konig, H. (1986): <i>Eigenvalue Distribution of Compact Operators</i> <b>Birkhauser</b> Basel,
  101.  *          Switzerland
  102.  *  </li>
  103.  *  <li>
  104.  *      Smola, A. J., A. Elisseff, B. Scholkopf, and R. C. Williamson (2000): Entropy Numbers for Convex
  105.  *          Combinations and mlps, in: <i>Advances in Large Margin Classifiers, A. Smola, P. Bartlett, B.
  106.  *          Scholkopf, and D. Schuurmans - editors</i> <b>MIT Press</b> Cambridge, MA
  107.  *  </li>
  108.  * </ul>
  109.  *
  110.  *  <br><br>
  111.  *  <ul>
  112.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  113.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/StatisticalLearningLibrary.md">Statistical Learning</a></li>
  114.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/learning">Agnostic Learning Bounds under Empirical Loss Minimization Schemes</a></li>
  115.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/learning/kernel">Statistical Learning Banach Mercer Kernels</a></li>
  116.  *  </ul>
  117.  *
  118.  * @author Lakshmi Krishnamurthy
  119.  */

  120. public abstract class DiagonalScalingOperator implements org.drip.spaces.cover.OperatorClassCoveringBounds {
  121.     private double[] _adblDiagonalScaler = null;
  122.     private double _dblScalingProductSupremumBound = java.lang.Double.NaN;

  123.     /**
  124.      * DiagonalScalingOperator Constructor
  125.      *
  126.      * @param adblDiagonalScaler The Diagonal Scaling Multiplier Array
  127.      *
  128.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  129.      */

  130.     public DiagonalScalingOperator (
  131.         final double[] adblDiagonalScaler)
  132.         throws java.lang.Exception
  133.     {
  134.         if (null == (_adblDiagonalScaler = adblDiagonalScaler))
  135.             throw new java.lang.Exception ("DiagonalScalingOperator Constructor: Invalid Inputs");

  136.         double dblScalingProduct = 1.;
  137.         int iScalingSize = _adblDiagonalScaler.length;

  138.         if (0 == iScalingSize)
  139.             throw new java.lang.Exception ("DiagonalScalingOperator Constructor: Invalid Inputs");

  140.         for (int i = 0; i < iScalingSize; ++i) {
  141.             if (!org.drip.numerical.common.NumberUtil.IsValid (_adblDiagonalScaler[i]) || 0. >
  142.                 _adblDiagonalScaler[i])
  143.                 throw new java.lang.Exception ("DiagonalScalingOperator Constructor: Invalid Inputs");

  144.             if (0 == i) _dblScalingProductSupremumBound = _adblDiagonalScaler[i];

  145.             if (i > 0) {
  146.                 if (_adblDiagonalScaler[i - 1] < _adblDiagonalScaler[i])
  147.                     throw new java.lang.Exception ("DiagonalScalingOperator Constructor: Invalid Inputs");

  148.                 double dblCurrentSupremumBound = java.lang.Math.pow ((dblScalingProduct *=
  149.                     _adblDiagonalScaler[i]) / iScalingSize, 1. / i);

  150.                 if (_dblScalingProductSupremumBound < dblCurrentSupremumBound)
  151.                     _dblScalingProductSupremumBound = dblCurrentSupremumBound;
  152.             }
  153.         }
  154.     }

  155.     /**
  156.      * Retrieve the Diagonal Scaling Multiplier Array
  157.      *
  158.      * @return The Diagonal Scaling Multiplier Array
  159.      */

  160.     public double[] scaler()
  161.     {
  162.         return _adblDiagonalScaler;
  163.     }

  164.     @Override public int entropyNumberIndex()
  165.     {
  166.         return _adblDiagonalScaler.length;
  167.     }

  168.     @Override public double entropyNumberLowerBound()
  169.     {
  170.         return _dblScalingProductSupremumBound;
  171.     }

  172.     @Override public double entropyNumberUpperBound()
  173.     {
  174.         return 6. * _dblScalingProductSupremumBound;
  175.     }
  176. }