IntegralOperatorEigenComponent.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>IntegralOperatorEigenComponent</i> holds the Eigen-Function Space and the Eigenvalue Functions/Spaces
  80.  * of the R<sup>x</sup> L<sub>2</sub> To R<sup>x</sup> L<sub>2</sub> Kernel Linear Integral Operator defined
  81.  * by:
  82.  *
  83.  *      T_k [f(.)] := Integral Over Input Space {k (., y) * f(y) * d[Prob(y)]}
  84.  *  
  85.  * <br><br>
  86.  *  The References are:
  87.  * <br><br>
  88.  * <ul>
  89.  *  <li>
  90.  *      Ash, R. (1965): <i>Information Theory</i> <b>Inter-science</b> New York
  91.  *  </li>
  92.  *  <li>
  93.  *      Konig, H. (1986): <i>Eigenvalue Distribution of Compact Operators</i> <b>Birkhauser</b> Basel,
  94.  *          Switzerland
  95.  *  </li>
  96.  *  <li>
  97.  *      Smola, A. J., A. Elisseff, B. Scholkopf, and R. C. Williamson (2000): Entropy Numbers for Convex
  98.  *          Combinations and mlps, in: <i>Advances in Large Margin Classifiers, A. Smola, P. Bartlett, B.
  99.  *          Scholkopf, and D. Schuurmans - editors</i> <b>MIT Press</b> Cambridge, MA
  100.  *  </li>
  101.  * </ul>
  102.  *
  103.  *  <br><br>
  104.  *  <ul>
  105.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  106.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/StatisticalLearningLibrary.md">Statistical Learning</a></li>
  107.  *      <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>
  108.  *      <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>
  109.  *  </ul>
  110.  *
  111.  * @author Lakshmi Krishnamurthy
  112.  */

  113. public class IntegralOperatorEigenComponent {
  114.     private double _dblEigenValue = java.lang.Double.NaN;
  115.     private org.drip.learning.kernel.EigenFunctionRdToR1 _efRdToR1 = null;
  116.     private org.drip.spaces.rxtor1.NormedRdToNormedR1 _rkhsFeatureMap = null;

  117.     /**
  118.      * IntegralOperatorEigenComponent Constructor
  119.      *
  120.      * @param efRdToR1 Normed R^d To Normed R^1 Eigen-Function
  121.      * @param dblEigenValue The Eigenvalue
  122.      *
  123.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  124.      */

  125.     public IntegralOperatorEigenComponent (
  126.         final org.drip.learning.kernel.EigenFunctionRdToR1 efRdToR1,
  127.         final double dblEigenValue)
  128.         throws java.lang.Exception
  129.     {
  130.         if (null == (_efRdToR1 = efRdToR1) || !org.drip.numerical.common.NumberUtil.IsValid (_dblEigenValue =
  131.             dblEigenValue))
  132.             throw new java.lang.Exception ("IntegralOperatorEigenComponent ctr: Invalid Inputs");

  133.         final org.drip.function.definition.RdToR1 eigenFuncRdToR1 = _efRdToR1.function();

  134.         if (null != eigenFuncRdToR1) {
  135.             org.drip.function.definition.RdToR1 rkhsFeatureMapRdToR1 = new
  136.                 org.drip.function.definition.RdToR1 (null) {
  137.                 @Override public int dimension()
  138.                 {
  139.                     return org.drip.function.definition.RdToR1.DIMENSION_NOT_FIXED;
  140.                 }

  141.                 @Override public double evaluate (
  142.                     final double[] adblX)
  143.                     throws java.lang.Exception
  144.                 {
  145.                     return java.lang.Math.sqrt (_dblEigenValue) * eigenFuncRdToR1.evaluate (adblX);
  146.                 }
  147.             };

  148.             org.drip.spaces.metric.RdNormed rdContinuousInput = efRdToR1.inputMetricVectorSpace();

  149.             org.drip.spaces.metric.R1Normed r1ContinuousOutput = efRdToR1.outputMetricVectorSpace();

  150.             org.drip.spaces.metric.R1Continuous r1Continuous = org.drip.spaces.metric.R1Continuous.Standard
  151.                 (r1ContinuousOutput.leftEdge(), r1ContinuousOutput.rightEdge(),
  152.                     r1ContinuousOutput.borelSigmaMeasure(), 2);

  153.             _rkhsFeatureMap = rdContinuousInput instanceof org.drip.spaces.metric.RdCombinatorialBanach ? new
  154.                 org.drip.spaces.rxtor1.NormedRdCombinatorialToR1Continuous
  155.                     ((org.drip.spaces.metric.RdCombinatorialBanach) rdContinuousInput, r1Continuous,
  156.                         rkhsFeatureMapRdToR1) : new org.drip.spaces.rxtor1.NormedRdContinuousToR1Continuous
  157.                             ((org.drip.spaces.metric.RdContinuousBanach) rdContinuousInput, r1Continuous,
  158.                                 rkhsFeatureMapRdToR1);
  159.         }
  160.     }

  161.     /**
  162.      * Retrieve the Eigen-Function
  163.      *
  164.      * @return The Eigen-Function
  165.      */

  166.     public org.drip.learning.kernel.EigenFunctionRdToR1 eigenFunction()
  167.     {
  168.         return _efRdToR1;
  169.     }

  170.     /**
  171.      * Retrieve the Eigenvalue
  172.      *
  173.      * @return The Eigenvalue
  174.      */

  175.     public double eigenvalue()
  176.     {
  177.         return _dblEigenValue;
  178.     }

  179.     /**
  180.      * Retrieve the Feature Map Space represented via the Reproducing Kernel Hilbert Space
  181.      *
  182.      * @return The Feature Map Space representation using the Reproducing Kernel Hilbert Space
  183.      */

  184.     public org.drip.spaces.rxtor1.NormedRdToNormedR1 rkhsFeatureMap()
  185.     {
  186.         return _rkhsFeatureMap;
  187.     }

  188.     /**
  189.      * Retrieve the RKHS Feature Map Parallelepiped Agnostic Upper Bound Length
  190.      *
  191.      * @return The RKHS Feature Map Parallelepiped Agnostic Upper Bound Length
  192.      */

  193.     public double rkhsFeatureParallelepipedLength()
  194.     {
  195.         return 2. * _efRdToR1.agnosticUpperBound() * java.lang.Math.sqrt (_dblEigenValue);
  196.     }

  197.     /**
  198.      * Compute the Eigen-Component Contribution to the Kernel Value
  199.      *
  200.      * @param adblX The X Variate Array
  201.      * @param adblY The Y Variate Array
  202.      *
  203.      * @return The Eigen-Component Contribution to the Kernel Value
  204.      *
  205.      * @throws java.lang.Exception Thrown if the Inputs are invalid
  206.      */

  207.     public double evaluate (
  208.         final double[] adblX,
  209.         final double[] adblY)
  210.         throws java.lang.Exception
  211.     {
  212.         org.drip.function.definition.RdToR1 eigenFuncRdToR1 = _efRdToR1.function();

  213.         return eigenFuncRdToR1.evaluate (adblX) * eigenFuncRdToR1.evaluate (adblY) * _dblEigenValue;
  214.     }
  215. }