NormedRxToNormedRxFinite.java

  1. package org.drip.spaces.functionclass;

  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>NormedRxToNormedRxFinite</i> exposes the Space of Functions that are a Transform from the Normed
  80.  * R<sup>x</sup> To Normed R<sup>d</sup> Spaces. The References are:
  81.  *
  82.  * <br><br>
  83.  *  <ul>
  84.  *      <li>
  85.  *          Carl, B. (1985): Inequalities of the Bernstein-Jackson type and the Degree of Compactness of
  86.  *              Operators in Banach Spaces <i>Annals of the Fourier Institute</i> <b>35 (3)</b> 79-118
  87.  *      </li>
  88.  *      <li>
  89.  *          Carl, B., and I. Stephani (1990): <i>Entropy, Compactness, and the Approximation of Operators</i>
  90.  *              <b>Cambridge University Press</b> Cambridge UK
  91.  *      </li>
  92.  *      <li>
  93.  *          Williamson, R. C., A. J. Smola, and B. Scholkopf (2000): Entropy Numbers of Linear Function
  94.  *              Classes, in: <i>Proceedings of the 13th Annual Conference on Computational Learning
  95.  *                  Theory</i> <b>ACM</b> New York
  96.  *      </li>
  97.  *  </ul>
  98.  *
  99.  * <br><br>
  100.  *  <ul>
  101.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  102.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/StatisticalLearningLibrary.md">Statistical Learning Library</a></li>
  103.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spaces/README.md">R<sup>1</sup> and R<sup>d</sup> Vector/Tensor Spaces (Validated and/or Normed), and Function Classes</a></li>
  104.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spaces/functionclass/README.md">Normed Finite Spaces Function Class</a></li>
  105.  *  </ul>
  106.  * <br><br>
  107.  *
  108.  * @author Lakshmi Krishnamurthy
  109.  */

  110. public abstract class NormedRxToNormedRxFinite {
  111.     private double _dblMaureyConstant = java.lang.Double.NaN;

  112.     protected NormedRxToNormedRxFinite (
  113.         final double dblMaureyConstant)
  114.         throws java.lang.Exception
  115.     {
  116.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblMaureyConstant = dblMaureyConstant) || 0. >=
  117.             _dblMaureyConstant)
  118.             throw new java.lang.Exception ("NormedRxToNormedRxFinite ctr => Invalid Inputs");
  119.     }

  120.     /**
  121.      * Retrieve the Input Vector Space
  122.      *
  123.      * @return The Input Vector Space
  124.      */

  125.     public abstract org.drip.spaces.metric.GeneralizedMetricVectorSpace inputMetricVectorSpace();

  126.     /**
  127.      * Retrieve the Output Vector Space
  128.      *
  129.      * @return The Output Vector Space
  130.      */

  131.     public abstract org.drip.spaces.metric.GeneralizedMetricVectorSpace outputMetricVectorSpace();

  132.     /**
  133.      * Compute the Operator Population Metric Norm
  134.      *
  135.      * @return The Operator Population Metric Norm
  136.      *
  137.      * @throws java.lang.Exception Thrown if the Operator Norm cannot be computed
  138.      */

  139.     public abstract double operatorPopulationMetricNorm()
  140.         throws java.lang.Exception;

  141.     /**
  142.      * Compute the Operator Population Supremum Norm
  143.      *
  144.      * @return The Operator Population Supremum Norm
  145.      *
  146.      * @throws java.lang.Exception Thrown if the Operator Population Supremum Norm cannot be computed
  147.      */

  148.     public abstract double operatorPopulationSupremumNorm()
  149.         throws java.lang.Exception;

  150.     /**
  151.      * Compute the Operator Sample Metric Norm
  152.      *
  153.      * @param gvvi The Validated Vector Space Instance
  154.      *
  155.      * @return The Operator Sample Metric Norm
  156.      *
  157.      * @throws java.lang.Exception Thrown if the Operator Norm cannot be computed
  158.      */

  159.     public abstract double operatorSampleMetricNorm (
  160.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi)
  161.         throws java.lang.Exception;

  162.     /**
  163.      * Compute the Operator Sample Supremum Norm
  164.      *
  165.      * @param gvvi The Validated Vector Space Instance
  166.      *
  167.      * @return The Operator Sample Supremum Norm
  168.      *
  169.      * @throws java.lang.Exception Thrown if the Operator Sample Supremum Norm cannot be computed
  170.      */

  171.     public abstract double operatorSampleSupremumNorm (
  172.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi)
  173.         throws java.lang.Exception;

  174.     /**
  175.      * Retrieve the Agnostic Covering Number Upper/Lower Bounds for the Function Class
  176.      *
  177.      * @return The Agnostic Covering Number Upper/Lower Bounds for the Function Class
  178.      */

  179.     public abstract org.drip.spaces.cover.FunctionClassCoveringBounds agnosticCoveringNumberBounds();

  180.     /**
  181.      * Retrieve the Maurey Constant
  182.      *
  183.      * @return The Maurey Constant
  184.      */

  185.     public double maureyConstant()
  186.     {
  187.         return _dblMaureyConstant;
  188.     }

  189.     /**
  190.      * Retrieve the Scale-Sensitive Covering Number Upper/Lower Bounds given the Specified Sample for the
  191.      *  Function Class
  192.      *
  193.      * @param gvvi The Validated Instance Vector Sequence
  194.      * @param funcR1ToR1FatShatter The Cover Fat Shattering Coefficient R^1 To R^1
  195.      *
  196.      * @return The Scale-Sensitive Covering Number Upper/Lower Bounds given the Specified Sample for the
  197.      *  Function Class
  198.      */

  199.     public org.drip.spaces.cover.FunctionClassCoveringBounds scaleSensitiveCoveringBounds (
  200.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi,
  201.         final org.drip.function.definition.R1ToR1 funcR1ToR1FatShatter)
  202.     {
  203.         if (null == gvvi || null == funcR1ToR1FatShatter) return null;

  204.         int iSampleSize = -1;

  205.         if (gvvi instanceof org.drip.spaces.instance.ValidatedR1) {
  206.             double[] adblInstance = ((org.drip.spaces.instance.ValidatedR1) gvvi).instance();

  207.             if (null == adblInstance) return null;

  208.             iSampleSize = adblInstance.length;
  209.         } else if (gvvi instanceof org.drip.spaces.instance.ValidatedRd) {
  210.             double[][] aadblInstance = ((org.drip.spaces.instance.ValidatedRd) gvvi).instance();

  211.             if (null == aadblInstance) return null;

  212.             iSampleSize = aadblInstance.length;
  213.         }

  214.         try {
  215.             return new org.drip.spaces.cover.ScaleSensitiveCoveringBounds (funcR1ToR1FatShatter,
  216.                 iSampleSize);
  217.         } catch (java.lang.Exception e) {
  218.             e.printStackTrace();
  219.         }

  220.         return null;
  221.     }

  222.     /**
  223.      * Compute the Output Dimension
  224.      *
  225.      * @return The Output Dimension
  226.      *
  227.      * @throws java.lang.Exception Thrown if the Output Dimension is Invalid
  228.      */

  229.     public int outputDimension()
  230.         throws java.lang.Exception
  231.     {
  232.         org.drip.spaces.metric.GeneralizedMetricVectorSpace gmvsOutput = outputMetricVectorSpace();

  233.         if (!(gmvsOutput instanceof org.drip.spaces.metric.R1Continuous) && !(gmvsOutput instanceof
  234.             org.drip.spaces.metric.RdContinuousBanach))
  235.             throw new java.lang.Exception ("NormedRxToNormedRxFinite::dimension => Invalid Inputs");

  236.         return gmvsOutput instanceof org.drip.spaces.metric.R1Continuous ? 1 :
  237.             ((org.drip.spaces.metric.RdContinuousBanach) gmvsOutput).dimension();
  238.     }

  239.     /**
  240.      * Compute the Maurey Covering Number Upper Bounds for Operator Population Metric Norm
  241.      *
  242.      * @return The Maurey Operator Covering Number Upper Bounds Instance Corresponding to the Operator
  243.      *  Population Metric Norm
  244.      */

  245.     public org.drip.spaces.cover.MaureyOperatorCoveringBounds populationMetricCoveringBounds()
  246.     {
  247.         try {
  248.             return new org.drip.spaces.cover.MaureyOperatorCoveringBounds (_dblMaureyConstant,
  249.                 outputDimension(), operatorPopulationMetricNorm());
  250.         } catch (java.lang.Exception e) {
  251.             e.printStackTrace();
  252.         }

  253.         return null;
  254.     }

  255.     /**
  256.      * Compute the Maurey Covering Number Upper Bounds for Operator Population Supremum Norm
  257.      *
  258.      * @return The Maurey Operator Covering Number Upper Bounds Instance Corresponding to the Operator
  259.      *  Population Supremum Norm
  260.      */

  261.     public org.drip.spaces.cover.MaureyOperatorCoveringBounds populationSupremumCoveringBounds()
  262.     {
  263.         try {
  264.             return new org.drip.spaces.cover.MaureyOperatorCoveringBounds (_dblMaureyConstant,
  265.                 outputDimension(), operatorPopulationSupremumNorm());
  266.         } catch (java.lang.Exception e) {
  267.             e.printStackTrace();
  268.         }

  269.         return null;
  270.     }

  271.     /**
  272.      * Compute the Maurey Covering Number Upper Bounds for Operator Sample Metric Norm
  273.      *
  274.      * @param gvvi The Validated Vector Space Instance
  275.      *
  276.      * @return The Maurey Operator Covering Number Upper Bounds Instance Corresponding to the Operator Sample
  277.      *  Metric Norm
  278.      */

  279.     public org.drip.spaces.cover.MaureyOperatorCoveringBounds sampleMetricCoveringBounds (
  280.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi)
  281.     {
  282.         try {
  283.             return new org.drip.spaces.cover.MaureyOperatorCoveringBounds (_dblMaureyConstant,
  284.                 outputDimension(), operatorSampleMetricNorm (gvvi));
  285.         } catch (java.lang.Exception e) {
  286.             e.printStackTrace();
  287.         }

  288.         return null;
  289.     }

  290.     /**
  291.      * Compute the Maurey Covering Number Upper Bounds for Operator Sample Supremum Norm
  292.      *
  293.      * @param gvvi The Validated Vector Space Instance
  294.      *
  295.      * @return The Maurey Operator Covering Number Upper Bounds Instance Corresponding to the Operator Sample
  296.      *  Supremum Norm
  297.      */

  298.     public org.drip.spaces.cover.MaureyOperatorCoveringBounds sampleSupremumCoveringBounds (
  299.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi)
  300.     {
  301.         try {
  302.             return new org.drip.spaces.cover.MaureyOperatorCoveringBounds (_dblMaureyConstant,
  303.                 outputDimension(), operatorSampleSupremumNorm (gvvi));
  304.         } catch (java.lang.Exception e) {
  305.             e.printStackTrace();
  306.         }

  307.         return null;
  308.     }
  309. }