IncompleteBetaEqualityLemma.java

  1. package org.drip.specialfunction.property;

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

  74. /**
  75.  * <i>IncompleteBetaEqualityLemma</i> implements the Equality Lemmas for the Incomplete Beta Estimation. The
  76.  * References are:
  77.  *
  78.  * <br><br>
  79.  *  <ul>
  80.  *      <li>
  81.  *          Abramowitz, M., and I. A. Stegun (2007): <i>Handbook of Mathematics Functions</i> <b>Dover Book
  82.  *              on Mathematics</b>
  83.  *      </li>
  84.  *      <li>
  85.  *          Davis, P. J. (1959): Leonhard Euler's Integral: A Historical Profile of the Gamma Function
  86.  *              <i>American Mathematical Monthly</i> <b>66 (10)</b> 849-869
  87.  *      </li>
  88.  *      <li>
  89.  *          Whitaker, E. T., and G. N. Watson (1996): <i>A Course on Modern Analysis</i> <b>Cambridge
  90.  *              University Press</b> New York
  91.  *      </li>
  92.  *      <li>
  93.  *          Wikipedia (2019): Beta Function https://en.wikipedia.org/wiki/Beta_function
  94.  *      </li>
  95.  *      <li>
  96.  *          Wikipedia (2019): Gamma Function https://en.wikipedia.org/wiki/Gamma_function
  97.  *      </li>
  98.  *  </ul>
  99.  *
  100.  *  <br><br>
  101.  *  <ul>
  102.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  103.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FunctionAnalysisLibrary.md">Function Analysis Library</a></li>
  104.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/specialfunction/README.md">Special Function Implementation Analysis</a></li>
  105.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/specialfunction/property/README.md">Special Function Property Lemma Verifiers</a></li>
  106.  *  </ul>
  107.  *
  108.  * @author Lakshmi Krishnamurthy
  109.  */

  110. public class IncompleteBetaEqualityLemma
  111. {

  112.     /**
  113.      * Construct the Identity #1 Verifier
  114.      *
  115.      * @return The Identity #1 Verifier
  116.      */

  117.     public static final org.drip.function.definition.R2ToR1Property Identity1()
  118.     {
  119.         try
  120.         {
  121.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  122.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  123.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  124.                     org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000)
  125.                         );

  126.             return new org.drip.function.definition.R2ToR1Property (
  127.                 org.drip.function.definition.RxToR1Property.EQ,
  128.                 new org.drip.function.definition.R2ToR1()
  129.                 {
  130.                     @Override public double evaluate (
  131.                         final double a,
  132.                         final double b)
  133.                         throws java.lang.Exception
  134.                     {
  135.                         if (!org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  136.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  137.                         {
  138.                             throw new java.lang.Exception
  139.                                 ("IncompleteBetaEqualityLemma::Identity1::evaluate => Invalid Inputs");
  140.                         }

  141.                         return incompleteRegularizedEstimator.evaluate (
  142.                             0.,
  143.                             a,
  144.                             b
  145.                         );
  146.                     }
  147.                 },
  148.                 new org.drip.function.definition.R2ToR1()
  149.                 {
  150.                     @Override public double evaluate (
  151.                         final double x,
  152.                         final double y)
  153.                         throws java.lang.Exception
  154.                     {
  155.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  156.                             !org.drip.numerical.common.NumberUtil.IsValid (y) || 0. >= y)
  157.                         {
  158.                             throw new java.lang.Exception
  159.                                 ("IncompleteBetaEqualityLemma::Identity1::evaluate => Invalid Inputs");
  160.                         }

  161.                         return 0.;
  162.                     }
  163.                 },
  164.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  165.             );
  166.         }
  167.         catch (java.lang.Exception e)
  168.         {
  169.             e.printStackTrace();
  170.         }

  171.         return null;
  172.     }

  173.     /**
  174.      * Construct the Identity #2 Verifier
  175.      *
  176.      * @return The Identity #2 Verifier
  177.      */

  178.     public static final org.drip.function.definition.R2ToR1Property Identity2()
  179.     {
  180.         try
  181.         {
  182.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  183.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  184.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  185.                     org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000)
  186.                         );

  187.             return new org.drip.function.definition.R2ToR1Property (
  188.                 org.drip.function.definition.RxToR1Property.EQ,
  189.                 new org.drip.function.definition.R2ToR1()
  190.                 {
  191.                     @Override public double evaluate (
  192.                         final double a,
  193.                         final double b)
  194.                         throws java.lang.Exception
  195.                     {
  196.                         if (!org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  197.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  198.                         {
  199.                             throw new java.lang.Exception
  200.                                 ("IncompleteBetaEqualityLemma::Identity2::evaluate => Invalid Inputs");
  201.                         }

  202.                         return incompleteRegularizedEstimator.evaluate (
  203.                             1.,
  204.                             a,
  205.                             b
  206.                         );
  207.                     }
  208.                 },
  209.                 new org.drip.function.definition.R2ToR1()
  210.                 {
  211.                     @Override public double evaluate (
  212.                         final double x,
  213.                         final double y)
  214.                         throws java.lang.Exception
  215.                     {
  216.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  217.                             !org.drip.numerical.common.NumberUtil.IsValid (y) || 0. >= y)
  218.                         {
  219.                             throw new java.lang.Exception
  220.                                 ("IncompleteBetaEqualityLemma::Identity2::evaluate => Invalid Inputs");
  221.                         }

  222.                         return 1.;
  223.                     }
  224.                 },
  225.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  226.             );
  227.         }
  228.         catch (java.lang.Exception e)
  229.         {
  230.             e.printStackTrace();
  231.         }

  232.         return null;
  233.     }

  234.     /**
  235.      * Construct the Identity #3 Verifier
  236.      *
  237.      * @return The Identity #3 Verifier
  238.      */

  239.     public static final org.drip.function.definition.R2ToR1Property Identity3()
  240.     {
  241.         try
  242.         {
  243.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  244.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  245.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  246.                     org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000)
  247.                         );

  248.             return new org.drip.function.definition.R2ToR1Property (
  249.                 org.drip.function.definition.RxToR1Property.EQ,
  250.                 new org.drip.function.definition.R2ToR1()
  251.                 {
  252.                     @Override public double evaluate (
  253.                         final double x,
  254.                         final double a)
  255.                         throws java.lang.Exception
  256.                     {
  257.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  258.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a)
  259.                         {
  260.                             throw new java.lang.Exception
  261.                                 ("IncompleteBetaEqualityLemma::Identity3::evaluate => Invalid Inputs");
  262.                         }

  263.                         return incompleteRegularizedEstimator.evaluate (
  264.                             x,
  265.                             a,
  266.                             1.
  267.                         );
  268.                     }
  269.                 },
  270.                 new org.drip.function.definition.R2ToR1()
  271.                 {
  272.                     @Override public double evaluate (
  273.                         final double x,
  274.                         final double a)
  275.                         throws java.lang.Exception
  276.                     {
  277.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  278.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a)
  279.                         {
  280.                             throw new java.lang.Exception
  281.                                 ("IncompleteBetaEqualityLemma::Identity3::evaluate => Invalid Inputs");
  282.                         }

  283.                         return java.lang.Math.pow (
  284.                             x,
  285.                             a
  286.                         );
  287.                     }
  288.                 },
  289.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  290.             );
  291.         }
  292.         catch (java.lang.Exception e)
  293.         {
  294.             e.printStackTrace();
  295.         }

  296.         return null;
  297.     }

  298.     /**
  299.      * Construct the Identity #4 Verifier
  300.      *
  301.      * @return The Identity #4 Verifier
  302.      */

  303.     public static final org.drip.function.definition.R2ToR1Property Identity4()
  304.     {
  305.         try
  306.         {
  307.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  308.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  309.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  310.                     org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000)
  311.                         );

  312.             return new org.drip.function.definition.R2ToR1Property (
  313.                 org.drip.function.definition.RxToR1Property.EQ,
  314.                 new org.drip.function.definition.R2ToR1()
  315.                 {
  316.                     @Override public double evaluate (
  317.                         final double x,
  318.                         final double b)
  319.                         throws java.lang.Exception
  320.                     {
  321.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  322.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  323.                         {
  324.                             throw new java.lang.Exception
  325.                                 ("IncompleteBetaEqualityLemma::Identity4::evaluate => Invalid Inputs");
  326.                         }

  327.                         return incompleteRegularizedEstimator.evaluate (
  328.                             x,
  329.                             1.,
  330.                             b
  331.                         );
  332.                     }
  333.                 },
  334.                 new org.drip.function.definition.R2ToR1()
  335.                 {
  336.                     @Override public double evaluate (
  337.                         final double x,
  338.                         final double b)
  339.                         throws java.lang.Exception
  340.                     {
  341.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  342.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  343.                         {
  344.                             throw new java.lang.Exception
  345.                                 ("IncompleteBetaEqualityLemma::Identity4::evaluate => Invalid Inputs");
  346.                         }

  347.                         return 1. - java.lang.Math.pow (
  348.                             1. - x,
  349.                             b
  350.                         );
  351.                     }
  352.                 },
  353.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  354.             );
  355.         }
  356.         catch (java.lang.Exception e)
  357.         {
  358.             e.printStackTrace();
  359.         }

  360.         return null;
  361.     }

  362.     /**
  363.      * Construct the Identity #5 Verifier
  364.      *
  365.      * @return The Identity #5 Verifier
  366.      */

  367.     public static final org.drip.function.definition.R3ToR1Property Identity5()
  368.     {
  369.         try
  370.         {
  371.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  372.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  373.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  374.                     org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000)
  375.                 );

  376.             return new org.drip.function.definition.R3ToR1Property (
  377.                 org.drip.function.definition.RxToR1Property.EQ,
  378.                 new org.drip.function.definition.R3ToR1()
  379.                 {
  380.                     @Override public double evaluate (
  381.                         final double x,
  382.                         final double a,
  383.                         final double b)
  384.                         throws java.lang.Exception
  385.                     {
  386.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  387.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  388.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  389.                         {
  390.                             throw new java.lang.Exception
  391.                                 ("IncompleteBetaEqualityLemma::Identity5::evaluate => Invalid Inputs");
  392.                         }

  393.                         return incompleteRegularizedEstimator.evaluate (
  394.                             x,
  395.                             a,
  396.                             b
  397.                         );
  398.                     }
  399.                 },
  400.                 new org.drip.function.definition.R3ToR1()
  401.                 {
  402.                     @Override public double evaluate (
  403.                         final double x,
  404.                         final double a,
  405.                         final double b)
  406.                         throws java.lang.Exception
  407.                     {
  408.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  409.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  410.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  411.                         {
  412.                             throw new java.lang.Exception
  413.                                 ("IncompleteBetaEqualityLemma::Identity5::evaluate => Invalid Inputs");
  414.                         }

  415.                         return 1. - incompleteRegularizedEstimator.evaluate (
  416.                             1. - x,
  417.                             b,
  418.                             a
  419.                         );
  420.                     }
  421.                 },
  422.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  423.             );
  424.         }
  425.         catch (java.lang.Exception e)
  426.         {
  427.             e.printStackTrace();
  428.         }

  429.         return null;
  430.     }

  431.     /**
  432.      * Construct the Identity #6 Verifier
  433.      *
  434.      * @return The Identity #6 Verifier
  435.      */

  436.     public static final org.drip.function.definition.R3ToR1Property Identity6()
  437.     {
  438.         final org.drip.specialfunction.beta.IntegrandEstimator integrandEstimator =
  439.             org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000);

  440.         try
  441.         {
  442.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  443.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  444.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  445.                     integrandEstimator
  446.                 );

  447.             return new org.drip.function.definition.R3ToR1Property (
  448.                 org.drip.function.definition.RxToR1Property.EQ,
  449.                 new org.drip.function.definition.R3ToR1()
  450.                 {
  451.                     @Override public double evaluate (
  452.                         final double x,
  453.                         final double a,
  454.                         final double b)
  455.                         throws java.lang.Exception
  456.                     {
  457.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  458.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  459.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  460.                         {
  461.                             throw new java.lang.Exception
  462.                                 ("IncompleteBetaEqualityLemma::Identity6::evaluate => Invalid Inputs");
  463.                         }

  464.                         return incompleteRegularizedEstimator.evaluate (
  465.                             x,
  466.                             a + 1.,
  467.                             b
  468.                         );
  469.                     }
  470.                 },
  471.                 new org.drip.function.definition.R3ToR1()
  472.                 {
  473.                     @Override public double evaluate (
  474.                         final double x,
  475.                         final double a,
  476.                         final double b)
  477.                         throws java.lang.Exception
  478.                     {
  479.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  480.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  481.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  482.                         {
  483.                             throw new java.lang.Exception
  484.                                 ("IncompleteBetaEqualityLemma::Identity6::evaluate => Invalid Inputs");
  485.                         }

  486.                         return incompleteRegularizedEstimator.evaluate (
  487.                             x,
  488.                             a,
  489.                             b
  490.                         ) - java.lang.Math.pow (
  491.                             x,
  492.                             a
  493.                         ) * java.lang.Math.pow (
  494.                             1. - x,
  495.                             b
  496.                         ) / a / integrandEstimator.evaluate (
  497.                             a,
  498.                             b
  499.                         );
  500.                     }
  501.                 },
  502.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  503.             );
  504.         }
  505.         catch (java.lang.Exception e)
  506.         {
  507.             e.printStackTrace();
  508.         }

  509.         return null;
  510.     }

  511.     /**
  512.      * Construct the Identity #7 Verifier
  513.      *
  514.      * @return The Identity #7 Verifier
  515.      */

  516.     public static final org.drip.function.definition.R3ToR1Property Identity7()
  517.     {
  518.         final org.drip.specialfunction.beta.IntegrandEstimator integrandEstimator =
  519.             org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000);

  520.         try
  521.         {
  522.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  523.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  524.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  525.                     integrandEstimator
  526.                 );

  527.             return new org.drip.function.definition.R3ToR1Property (
  528.                 org.drip.function.definition.RxToR1Property.EQ,
  529.                 new org.drip.function.definition.R3ToR1()
  530.                 {
  531.                     @Override public double evaluate (
  532.                         final double x,
  533.                         final double a,
  534.                         final double b)
  535.                         throws java.lang.Exception
  536.                     {
  537.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  538.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  539.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  540.                         {
  541.                             throw new java.lang.Exception
  542.                                 ("IncompleteBetaEqualityLemma::Identity7::evaluate => Invalid Inputs");
  543.                         }

  544.                         return incompleteRegularizedEstimator.evaluate (
  545.                             x,
  546.                             a,
  547.                             b + 1.
  548.                         );
  549.                     }
  550.                 },
  551.                 new org.drip.function.definition.R3ToR1()
  552.                 {
  553.                     @Override public double evaluate (
  554.                         final double x,
  555.                         final double a,
  556.                         final double b)
  557.                         throws java.lang.Exception
  558.                     {
  559.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  560.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  561.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  562.                         {
  563.                             throw new java.lang.Exception
  564.                                 ("IncompleteBetaEqualityLemma::Identity7::evaluate => Invalid Inputs");
  565.                         }

  566.                         return incompleteRegularizedEstimator.evaluate (
  567.                             x,
  568.                             a,
  569.                             b
  570.                         ) + java.lang.Math.pow (
  571.                             x,
  572.                             a
  573.                         ) * java.lang.Math.pow (
  574.                             1. - x,
  575.                             b
  576.                         ) / b / integrandEstimator.evaluate (
  577.                             a,
  578.                             b
  579.                         );
  580.                     }
  581.                 },
  582.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  583.             );
  584.         }
  585.         catch (java.lang.Exception e)
  586.         {
  587.             e.printStackTrace();
  588.         }

  589.         return null;
  590.     }

  591.     /**
  592.      * Construct the Identity #8 Verifier
  593.      *
  594.      * @return The Identity #8 Verifier
  595.      */

  596.     public static final org.drip.function.definition.R3ToR1Property Identity8()
  597.     {
  598.         final org.drip.specialfunction.beta.IntegrandEstimator integrandEstimator =
  599.             org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000);

  600.         try
  601.         {
  602.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  603.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  604.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  605.                     integrandEstimator
  606.                 );

  607.             return new org.drip.function.definition.R3ToR1Property (
  608.                 org.drip.function.definition.RxToR1Property.EQ,
  609.                 new org.drip.function.definition.R3ToR1()
  610.                 {
  611.                     @Override public double evaluate (
  612.                         final double x,
  613.                         final double a,
  614.                         final double b)
  615.                         throws java.lang.Exception
  616.                     {
  617.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  618.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  619.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  620.                         {
  621.                             throw new java.lang.Exception
  622.                                 ("IncompleteBetaEqualityLemma::Identity8::evaluate => Invalid Inputs");
  623.                         }

  624.                         return incompleteRegularizedEstimator.evaluate (
  625.                             x,
  626.                             a,
  627.                             b
  628.                         );
  629.                     }
  630.                 },
  631.                 new org.drip.function.definition.R3ToR1()
  632.                 {
  633.                     @Override public double evaluate (
  634.                         final double x,
  635.                         final double a,
  636.                         final double b)
  637.                         throws java.lang.Exception
  638.                     {
  639.                         if (!org.drip.numerical.common.NumberUtil.IsValid (x) || 0. >= x ||
  640.                             !org.drip.numerical.common.NumberUtil.IsValid (a) || 0. >= a ||
  641.                             !org.drip.numerical.common.NumberUtil.IsValid (b) || 0. >= b)
  642.                         {
  643.                             throw new java.lang.Exception
  644.                                 ("IncompleteBetaEqualityLemma::Identity8::evaluate => Invalid Inputs");
  645.                         }

  646.                         return incompleteRegularizedEstimator.evaluate (
  647.                             x / (1. - x),
  648.                             a,
  649.                             1. - a - b
  650.                         );
  651.                     }
  652.                 },
  653.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  654.             );
  655.         }
  656.         catch (java.lang.Exception e)
  657.         {
  658.             e.printStackTrace();
  659.         }

  660.         return null;
  661.     }

  662.     /**
  663.      * Construct the Cumulative Binomial Distribution Verifier
  664.      *
  665.      * @return The Cumulative Binomial Distribution Verifier
  666.      */

  667.     public static final org.drip.function.definition.R3ToR1Property CumulativeBinomialDistribution()
  668.     {
  669.         try
  670.         {
  671.             final org.drip.specialfunction.beta.IncompleteRegularizedEstimator incompleteRegularizedEstimator
  672.                 = new org.drip.specialfunction.beta.IncompleteRegularizedEstimator (
  673.                     org.drip.specialfunction.beta.IncompleteIntegrandEstimator.EulerFirst (1000),
  674.                     org.drip.specialfunction.beta.IntegrandEstimator.EulerFirstRightPlane (1000)
  675.                 );

  676.             return new org.drip.function.definition.R3ToR1Property (
  677.                 org.drip.function.definition.RxToR1Property.EQ,
  678.                 new org.drip.function.definition.R3ToR1()
  679.                 {
  680.                     @Override public double evaluate (
  681.                         final double p,
  682.                         final double n,
  683.                         final double k)
  684.                         throws java.lang.Exception
  685.                     {
  686.                         if (!org.drip.numerical.common.NumberUtil.IsValid (p) || 0. >= p ||
  687.                             !org.drip.numerical.common.NumberUtil.IsValid (n) || 0. >= n ||
  688.                             !org.drip.numerical.common.NumberUtil.IsValid (k) || 0. >= k)
  689.                         {
  690.                             throw new java.lang.Exception
  691.                                 ("IncompleteBetaEqualityLemma::CumulativeBinomialDistribution::evaluate => Invalid Inputs");
  692.                         }

  693.                         return incompleteRegularizedEstimator.evaluate (
  694.                             1. - p,
  695.                             n - k,
  696.                             k + 1.
  697.                         );
  698.                     }
  699.                 },
  700.                 new org.drip.function.definition.R3ToR1()
  701.                 {
  702.                     @Override public double evaluate (
  703.                         final double p,
  704.                         final double n,
  705.                         final double k)
  706.                         throws java.lang.Exception
  707.                     {
  708.                         if (!org.drip.numerical.common.NumberUtil.IsValid (p) || 0. >= p ||
  709.                             !org.drip.numerical.common.NumberUtil.IsValid (n) || 0. >= n ||
  710.                             !org.drip.numerical.common.NumberUtil.IsValid (k) || 0. >= k)
  711.                         {
  712.                             throw new java.lang.Exception
  713.                                 ("IncompleteBetaEqualityLemma::CumulativeBinomialDistribution::evaluate => Invalid Inputs");
  714.                         }

  715.                         return 1. - incompleteRegularizedEstimator.evaluate (
  716.                             p,
  717.                             k + 1.,
  718.                             n - k
  719.                         );
  720.                     }
  721.                 },
  722.                 org.drip.function.definition.R1ToR1Property.MISMATCH_TOLERANCE
  723.             );
  724.         }
  725.         catch (java.lang.Exception e)
  726.         {
  727.             e.printStackTrace();
  728.         }

  729.         return null;
  730.     }
  731. }