DecisionFunctionOperatorBounds.java

  1. package org.drip.learning.svm;

  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>DecisionFunctionOperatorBounds</i> implements the Dot Product Entropy Number Upper Bounds for the
  80.  * Product of Kernel Feature Map Function and the Scaling Diagonal Operator.
  81.  *  
  82.  * <br><br>
  83.  *  The References are:
  84.  * <br><br>
  85.  * <ul>
  86.  *  <li>
  87.  *      Ash, R. (1965): <i>Information Theory</i> <b>Inter-science</b> New York
  88.  *  </li>
  89.  *  <li>
  90.  *      Carl, B., and I. Stephani (1990): <i>Entropy, Compactness, and Approximation of Operators</i>
  91.  *          <b>Cambridge University Press</b> Cambridge UK
  92.  *  </li>
  93.  *  <li>
  94.  *      Gordon, Y., H. Konig, and C. Schutt (1987): Geometric and Probabilistic Estimates of Entropy and
  95.  *          Approximation Numbers of Operators <i>Journal of Approximation Theory</i> <b>49</b> 219-237
  96.  *  </li>
  97.  *  <li>
  98.  *      Konig, H. (1986): <i>Eigenvalue Distribution of Compact Operators</i> <b>Birkhauser</b> Basel,
  99.  *          Switzerland
  100.  *  </li>
  101.  *  <li>
  102.  *      Smola, A. J., A. Elisseff, B. Scholkopf, and R. C. Williamson (2000): Entropy Numbers for Convex
  103.  *          Combinations and mlps, in: <i>Advances in Large Margin Classifiers, A. Smola, P. Bartlett, B.
  104.  *          Scholkopf, and D. Schuurmans - editors</i> <b>MIT Press</b> Cambridge, MA
  105.  *  </li>
  106.  * </ul>
  107.  *
  108.  *  <br><br>
  109.  *  <ul>
  110.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  111.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/StatisticalLearningLibrary.md">Statistical Learning</a></li>
  112.  *      <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>
  113.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/learning/svm">Kernel SVM Decision Function Operator</a></li>
  114.  *  </ul>
  115.  *
  116.  * @author Lakshmi Krishnamurthy
  117.  */

  118. public class DecisionFunctionOperatorBounds {
  119.     private int _iFeatureSpaceDimension = -1;
  120.     private double _dblInverseMarginNormBound = java.lang.Double.NaN;
  121.     private double _dblFeatureSpaceMaureyConstant = java.lang.Double.NaN;
  122.     private org.drip.learning.kernel.DiagonalScalingOperator _dsoFactorizer = null;

  123.     /**
  124.      * DecisionFunctionOperatorBounds Constructor
  125.      *
  126.      * @param dsoFactorizer The Factorizing Diagonal Scaling Operator
  127.      * @param dblInverseMarginNormBound The Decision Function Inverse Margin Norm Bound
  128.      * @param dblFeatureSpaceMaureyConstant The Kernel Feature Space Function Maurey Constant
  129.      * @param iFeatureSpaceDimension The Kernel Feature Space Dimension
  130.      *
  131.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  132.      */

  133.     public DecisionFunctionOperatorBounds (
  134.         final org.drip.learning.kernel.DiagonalScalingOperator dsoFactorizer,
  135.         final double dblInverseMarginNormBound,
  136.         final double dblFeatureSpaceMaureyConstant,
  137.         final int iFeatureSpaceDimension)
  138.         throws java.lang.Exception
  139.     {
  140.         if (null == (_dsoFactorizer = dsoFactorizer) || !org.drip.numerical.common.NumberUtil.IsValid
  141.             (_dblInverseMarginNormBound = dblInverseMarginNormBound) ||
  142.                 !org.drip.numerical.common.NumberUtil.IsValid (_dblFeatureSpaceMaureyConstant =
  143.                     dblFeatureSpaceMaureyConstant) || 0 >= (_iFeatureSpaceDimension =
  144.                         iFeatureSpaceDimension))
  145.             throw new java.lang.Exception ("DecisionFunctionOperatorBounds ctr => Invalid Inputs");
  146.     }

  147.     /**
  148.      * Retrieve the Factorizing Diagonal Scaling Operator Instance
  149.      *
  150.      * @return The Factorizing Diagonal Scaling Operator Instance
  151.      */

  152.     public org.drip.learning.kernel.DiagonalScalingOperator factorizingOperator()
  153.     {
  154.         return _dsoFactorizer;
  155.     }

  156.     /**
  157.      * Retrieve the Norm Upper Bound of the Inverse Margin
  158.      *
  159.      * @return The Norm Upper Bound of the Inverse Margin
  160.      */

  161.     public double inverseMarginNormBound()
  162.     {
  163.         return _dblInverseMarginNormBound;
  164.     }

  165.     /**
  166.      * Retrieve the Feature Space Maurey Constant
  167.      *
  168.      * @return The Feature Space Maurey Constant
  169.      */

  170.     public double featureSpaceMaureyConstant()
  171.     {
  172.         return _dblFeatureSpaceMaureyConstant;
  173.     }

  174.     /**
  175.      * Retrieve the Feature Space Dimension
  176.      *
  177.      * @return The Feature Space Dimension
  178.      */

  179.     public double featureSpaceDimension()
  180.     {
  181.         return _iFeatureSpaceDimension;
  182.     }

  183.     /**
  184.      * Compute the Feature Space's Maurey Bound for the Entropy Number given the specified Entropy Number
  185.      *
  186.      * @param iFeatureSpaceEntropyNumber The Feature Space Entropy Number
  187.      *
  188.      * @return The Feature Space's Maurey Bound for the specified Entropy Number
  189.      *
  190.      * @throws java.lang.Exception The Feature Space's Maurey Bound cannot be computed
  191.      */

  192.     public double featureSpaceMaureyBound (
  193.         final int iFeatureSpaceEntropyNumber)
  194.         throws java.lang.Exception
  195.     {
  196.         if (0 >= iFeatureSpaceEntropyNumber)
  197.             throw new java.lang.Exception
  198.                 ("DecisionFunctionOperatorBounds::featureSpaceMaureyBound => Invalid Inputs");

  199.         return java.lang.Math.sqrt (1. / (iFeatureSpaceEntropyNumber * java.lang.Math.sqrt
  200.             (java.lang.Math.log (1. + (((double) _iFeatureSpaceDimension) / java.lang.Math.log
  201.                 (iFeatureSpaceEntropyNumber))))));
  202.     }

  203.     /**
  204.      * Compute the Decision Function Entropy Number Upper Bound using the Product of the Feature Space's
  205.      *  Maurey Upper Bound for the Entropy for the specified Entropy Number and the Scaling Operator Entropy
  206.      *  Number Upper Bound
  207.      *
  208.      * @param iFeatureSpaceEntropyNumber The Feature Space Entropy Number
  209.      *
  210.      * @return The Feature Space's Operator Entropy for the specified Entropy Number
  211.      *
  212.      * @throws java.lang.Exception The Feature Space's Operator Entropy cannot be computed
  213.      */

  214.     public double featureMaureyOperatorEntropy (
  215.         final int iFeatureSpaceEntropyNumber)
  216.         throws java.lang.Exception
  217.     {
  218.         return _dblInverseMarginNormBound * _dsoFactorizer.entropyNumberUpperBound() *
  219.             featureSpaceMaureyBound (iFeatureSpaceEntropyNumber);
  220.     }

  221.     /**
  222.      * Compute the Decision Function Entropy Number Upper Bound using the Product of the Feature Space's
  223.      *  Maurey Upper Bound for the Entropy for the specified Entropy Number and the Scaling Operator Norm
  224.      *
  225.      * @param iFeatureSpaceEntropyNumber The Feature Space Entropy Number
  226.      *
  227.      * @return The Feature Space's Operator Norm for the specified Entropy Number
  228.      *
  229.      * @throws java.lang.Exception The Feature Space's Operator Norm cannot be computed
  230.      */

  231.     public double featureMaureyOperatorNorm (
  232.         final int iFeatureSpaceEntropyNumber)
  233.         throws java.lang.Exception
  234.     {
  235.         return _dblInverseMarginNormBound * _dsoFactorizer.norm() * featureSpaceMaureyBound
  236.             (iFeatureSpaceEntropyNumber);
  237.     }

  238.     /**
  239.      * Compute the Decision Function Entropy Number Upper Bound using the Product of the Feature Space's
  240.      *  Norm for the Upper Bound of the Entropy Number and the Scaling Operator Norm
  241.      *
  242.      * @return The Entropy Number Upper Bound using the Product Norm
  243.      *
  244.      * @throws java.lang.Exception The Entropy Number Upper Bound cannot be computed
  245.      */

  246.     public double productFeatureOperatorNorm()
  247.         throws java.lang.Exception
  248.     {
  249.         return _dblInverseMarginNormBound * _dsoFactorizer.norm();
  250.     }

  251.     /**
  252.      * Compute the Decision Function Entropy Number Upper Bound using the Product of the Feature Space's
  253.      *  Norm for the Upper Bound of the Entropy Number and the Scaling Operator Entropy Number Upper Bound
  254.      *
  255.      * @return The Entropy Number Upper Bound using the Product Norm
  256.      *
  257.      * @throws java.lang.Exception The Entropy Number Upper Bound cannot be computed
  258.      */

  259.     public double featureNormOperatorEntropy()
  260.         throws java.lang.Exception
  261.     {
  262.         return _dblInverseMarginNormBound * _dsoFactorizer.entropyNumberUpperBound();
  263.     }

  264.     /**
  265.      * Compute the Infimum of the Decision Function Operator Upper Bound across all the Product Bounds for
  266.      *  the specified Feature Space Entropy Number
  267.      *
  268.      * @param iFeatureSpaceEntropyNumber The specified Feature Space Entropy Number
  269.      *
  270.      * @return Infimum of the Decision Function Operator Upper Bound
  271.      *
  272.      * @throws java.lang.Exception Thrown if the Infimum of the Decision Function Operator Upper Bound cannot
  273.      *  be calculated
  274.      */

  275.     public double infimumUpperBound (
  276.         final int iFeatureSpaceEntropyNumber)
  277.         throws java.lang.Exception
  278.     {
  279.         double dblFactorizerNorm = _dsoFactorizer.norm();

  280.         double dblFactorizerEntropyUpperBound = _dsoFactorizer.entropyNumberUpperBound();

  281.         double dblFeatureSpaceMaureyBound = featureSpaceMaureyBound (iFeatureSpaceEntropyNumber);

  282.         double dblProductFeatureOperatorNorm = _dblInverseMarginNormBound * dblFactorizerNorm;
  283.         double dblFeatureMaureyOperatorNorm = dblProductFeatureOperatorNorm * dblFeatureSpaceMaureyBound;
  284.         double dblFeatureNormOperatorEntropy = _dblInverseMarginNormBound * dblFactorizerEntropyUpperBound;
  285.         double dblInfimumUpperBound = dblFeatureNormOperatorEntropy * dblFeatureSpaceMaureyBound;

  286.         if (dblInfimumUpperBound > dblFeatureMaureyOperatorNorm)
  287.             dblInfimumUpperBound = dblFeatureMaureyOperatorNorm;

  288.         if (dblInfimumUpperBound > dblProductFeatureOperatorNorm)
  289.             dblInfimumUpperBound = dblProductFeatureOperatorNorm;

  290.         return dblInfimumUpperBound > dblFeatureNormOperatorEntropy ? dblInfimumUpperBound :
  291.             dblFeatureNormOperatorEntropy;
  292.     }
  293. }