NormedRxToNormedRd.java

  1. package org.drip.spaces.rxtord;

  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>NormedRxToNormedRd</i> is the Abstract Class that exposes f : Normed R<sup>x</sup> (x .gte. 1) To
  80.  * Normed R<sup>d</sup> Function Space. The Reference we've used is:
  81.  *
  82.  * <br><br>
  83.  *  <ul>
  84.  *      <li>
  85.  *          Carl, B., and I. Stephani (1990): <i>Entropy, Compactness, and the Approximation of Operators</i>
  86.  *              <b>Cambridge University Press</b> Cambridge UK
  87.  *      </li>
  88.  *  </ul>
  89.  *
  90.  * <br><br>
  91.  *  <ul>
  92.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  93.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/StatisticalLearningLibrary.md">Statistical Learning Library</a></li>
  94.  *      <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>
  95.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/spaces/rxtord/README.md">R<sup>x</sup> To R<sup>d</sup> Normed Function Spaces</a></li>
  96.  *  </ul>
  97.  * <br><br>
  98.  *
  99.  * @author Lakshmi Krishnamurthy
  100.  */

  101. public abstract class NormedRxToNormedRd {

  102.     /**
  103.      * Retrieve the Input Metric Vector Space
  104.      *
  105.      * @return The Input Metric Vector Space
  106.      */

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

  108.     /**
  109.      * Retrieve the Output Metric Vector Space
  110.      *
  111.      * @return The Output Metric Vector Space
  112.      */

  113.     public abstract org.drip.spaces.metric.RdNormed outputMetricVectorSpace();

  114.     /**
  115.      * Retrieve the Sample Supremum Norm Array
  116.      *
  117.      * @param gvvi The Validated Vector Space Instance
  118.      *
  119.      * @return The Sample Supremum Norm Array
  120.      */

  121.     public abstract double[] sampleSupremumNorm (
  122.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi);

  123.     /**
  124.      * Retrieve the Sample Metric Norm Array
  125.      *
  126.      * @param gvvi The Validated Vector Space Instance
  127.      *
  128.      * @return The Sample Metric Norm Array
  129.      */

  130.     public abstract double[] sampleMetricNorm (
  131.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi);

  132.     /**
  133.      * Retrieve the Sample Covering Number Array
  134.      *
  135.      * @param gvvi The Validated Vector Space Instance
  136.      * @param dblCover The Cover
  137.      *
  138.      * @return The Sample Covering Number Array
  139.      */

  140.     public double[] sampleCoveringNumber (
  141.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi,
  142.         final double dblCover)
  143.     {
  144.         if (!org.drip.numerical.common.NumberUtil.IsValid (dblCover) || 0. >= dblCover) return null;

  145.         double[] adblSampleMetricNorm = sampleMetricNorm (gvvi);

  146.         if (null == adblSampleMetricNorm) return null;

  147.         int iOutputDimensionality = adblSampleMetricNorm.length;
  148.         double[] adblSampleCoveringNumber = new double[iOutputDimensionality];

  149.         if (0 == iOutputDimensionality) return null;

  150.         double dblCoverBallVolume = java.lang.Math.pow (dblCover, outputMetricVectorSpace().pNorm());

  151.         for (int i = 0; i < iOutputDimensionality; ++i)
  152.             adblSampleCoveringNumber[i] = adblSampleMetricNorm[i] / dblCoverBallVolume;

  153.         return adblSampleCoveringNumber;
  154.     }

  155.     /**
  156.      * Retrieve the Sample Supremum Covering Number Array
  157.      *
  158.      * @param gvvi The Validated Vector Space Instance
  159.      * @param dblCover The Cover
  160.      *
  161.      * @return The Sample Supremum Covering Number Array
  162.      */

  163.     public double[] sampleSupremumCoveringNumber (
  164.         final org.drip.spaces.instance.GeneralizedValidatedVector gvvi,
  165.         final double dblCover)
  166.     {
  167.         if (!org.drip.numerical.common.NumberUtil.IsValid (dblCover) || 0. >= dblCover) return null;

  168.         double[] adblSampleSupremumNorm = sampleSupremumNorm (gvvi);

  169.         if (null == adblSampleSupremumNorm) return null;

  170.         int iOutputDimensionality = adblSampleSupremumNorm.length;
  171.         double[] adblSampleSupremumCoveringNumber = new double[iOutputDimensionality];

  172.         if (0 == iOutputDimensionality) return null;

  173.         double dblCoverBallVolume = java.lang.Math.pow (dblCover, outputMetricVectorSpace().pNorm());

  174.         for (int i = 0; i < iOutputDimensionality; ++i)
  175.             adblSampleSupremumCoveringNumber[i] = adblSampleSupremumNorm[i] / dblCoverBallVolume;

  176.         return adblSampleSupremumCoveringNumber;
  177.     }

  178.     /**
  179.      * Retrieve the Population ESS (Essential Spectrum) Array
  180.      *
  181.      * @return The Population ESS (Essential Spectrum) Array
  182.      */

  183.     public abstract double[] populationESS();

  184.     /**
  185.      * Retrieve the Population Metric Norm Array
  186.      *
  187.      * @return The Population Metric Norm Array
  188.      */

  189.     public abstract double[] populationMetricNorm();

  190.     /**
  191.      * Retrieve the Population Supremum Norm Array
  192.      *
  193.      * @return The Population Supremum Norm Array
  194.      */

  195.     public double[] populationSupremumNorm()
  196.     {
  197.         return populationMetricNorm();
  198.     }

  199.     /**
  200.      * Retrieve the Population Covering Number Array
  201.      *
  202.      * @param dblCover The Cover
  203.      *
  204.      * @return The Population Covering Number Array
  205.      */

  206.     public double[] populationCoveringNumber (
  207.         final double dblCover)
  208.     {
  209.         if (!org.drip.numerical.common.NumberUtil.IsValid (dblCover) || 0. >= dblCover) return null;

  210.         double[] adblPopulationMetricNorm = populationMetricNorm();

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

  212.         int iOutputDimensionality = adblPopulationMetricNorm.length;
  213.         double[] adblPopulationCoveringNumber = new double[iOutputDimensionality];

  214.         if (0 == iOutputDimensionality) return null;

  215.         double dblCoverBallVolume = java.lang.Math.pow (dblCover, outputMetricVectorSpace().pNorm());

  216.         for (int i = 0; i < iOutputDimensionality; ++i)
  217.             adblPopulationCoveringNumber[i] = adblPopulationMetricNorm[i] / dblCoverBallVolume;

  218.         return adblPopulationCoveringNumber;
  219.     }

  220.     /**
  221.      * Retrieve the Population Supremum Covering Number Array
  222.      *
  223.      * @param dblCover The Cover
  224.      *
  225.      * @return The Population Supremum Covering Number Array
  226.      */

  227.     public double[] populationSupremumCoveringNumber (
  228.         final double dblCover)
  229.     {
  230.         if (!org.drip.numerical.common.NumberUtil.IsValid (dblCover) || 0. >= dblCover) return null;

  231.         double[] adblPopulationSupremumNorm = populationSupremumNorm();

  232.         if (null == adblPopulationSupremumNorm) return null;

  233.         int iOutputDimensionality = adblPopulationSupremumNorm.length;
  234.         double[] adblPopulationSupremumCoveringNumber = new double[iOutputDimensionality];

  235.         if (0 == iOutputDimensionality) return null;

  236.         double dblCoverBallVolume = java.lang.Math.pow (dblCover, outputMetricVectorSpace().pNorm());

  237.         for (int i = 0; i < iOutputDimensionality; ++i)
  238.             adblPopulationSupremumCoveringNumber[i] = adblPopulationSupremumNorm[i] / dblCoverBallVolume;

  239.         return adblPopulationSupremumCoveringNumber;
  240.     }
  241. }