/// <summary>
 /// Returns the integral from zero to <tt>x</tt> of the gamma probability
 /// density function.
 /// <pre>
 ///                x
 ///        b       -
 ///       a       | |   b-1  -at
 /// y =  -----    |    t    e    dt
 ///       -     | |
 ///      | (b)   -
 ///               0
 /// </pre>
 /// The incomplete gamma integral is used, according to the
 /// relation
 ///
 /// <tt>y = Gamma.incompleteGamma( b, a*x )</tt>.
 /// </summary>
 /// <param name="a"> the paramater a (alpha) of the gamma distribution. </param>
 /// <param name="b"> the paramater b (beta, lambda) of the gamma distribution. </param>
 /// <param name="x"> integration end point. </param>
 /// <returns> result </returns>
 public static double gamma(double a, double b, double x)
 {
     if (x < 0.0)
     {
         return(0.0);
     }
     return(GammaFunctions.incompleteGamma(b, a * x));
 }
        /// <summary>
        /// Returns the area under the left hand tail (from 0 to <tt>x</tt>)
        /// of the Chi square probability density function with
        /// <tt>v</tt> degrees of freedom.
        /// <pre>
        ///                                  inf.
        ///                                    -
        ///                        1          | |  v/2-1  -t/2
        ///  P( x | v )   =   -----------     |   t      e     dt
        ///                    v/2  -       | |
        ///                   2    | (v/2)   -
        ///                                   x
        /// </pre>
        /// where <tt>x</tt> is the Chi-square variable.
        /// <para>
        /// The incomplete gamma integral is used, according to the
        /// formula
        /// </para>
        /// <para>
        /// <tt>y = chiSquare( v, x ) = incompleteGamma( v/2.0, x/2.0 )</tt>.
        /// </para>
        /// <para>
        /// The arguments must both be positive.
        ///
        /// </para>
        /// </summary>
        /// <param name="v"> degrees of freedom. </param>
        /// <param name="x"> integration end point. </param>
        /// <returns> result </returns>
        /// <exception cref="ArithmeticException"> error </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static double chiSquare(double v, double x) throws ArithmeticException
        public static double chiSquare(double v, double x)
        {
            if (x < 0.0 || v < 1.0)
            {
                return(0.0);
            }
            return(GammaFunctions.incompleteGamma(v / 2.0, x / 2.0));
        }
        /// <summary>
        /// Returns the sum of the terms <tt>k+1</tt> to <tt>Infinity</tt> of the Poisson distribution.
        /// <pre>
        ///  inf.       j
        ///   --   -m  m
        ///   >   e    --
        ///   --       j!
        ///  j=k+1
        /// </pre>
        /// The terms are not summed directly; instead the incomplete
        /// gamma integral is employed, according to the formula
        /// <para>
        /// <tt>y = poissonComplemented( k, m ) = Gamma.incompleteGamma( k+1, m )</tt>.
        ///
        /// The arguments must both be positive.
        ///
        /// </para>
        /// </summary>
        /// <param name="k"> start term. </param>
        /// <param name="mean"> the mean of the poisson distribution. </param>
        /// <returns> result </returns>
        /// <exception cref="ArithmeticException"> error </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static double poissonComplemented(int k, double mean) throws ArithmeticException
        public static double poissonComplemented(int k, double mean)
        {
            if (mean < 0)
            {
                throw new System.ArgumentException();
            }
            if (k < -1)
            {
                return(0.0);
            }
            return(GammaFunctions.incompleteGamma((double)(k + 1), mean));
        }