/// <summary>
 /// Returns the integral from <tt>x</tt> to infinity of the gamma
 /// probability density function:
 /// <pre>
 ///               inf.
 ///        b       -
 ///       a       | |   b-1  -at
 /// y =  -----    |    t    e    dt
 ///       -     | |
 ///      | (b)   -
 ///               x
 /// </pre>
 /// The incomplete gamma integral is used, according to the
 /// relation
 /// <para>
 /// y = Gamma.incompleteGammaComplement( b, a*x ).
 ///
 /// </para>
 /// </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 gammaComplemented(double a, double b, double x)
 {
     if (x < 0.0)
     {
         return(0.0);
     }
     return(GammaFunctions.incompleteGammaComplement(b, a * x));
 }
        /// <summary>
        /// Returns the area under the right hand tail (from <tt>x</tt> to
        /// infinity) 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.
        ///
        /// The incomplete gamma integral is used, according to the
        /// formula
        ///
        /// <tt>y = chiSquareComplemented( v, x ) = incompleteGammaComplement( v/2.0, x/2.0 )</tt>.
        ///
        ///
        /// The arguments must both be positive.
        /// </summary>
        /// <param name="v"> degrees of freedom. </param>
        /// <param name="x"> x </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 chiSquareComplemented(double v, double x) throws ArithmeticException
        public static double chiSquareComplemented(double v, double x)
        {
            if (x < 0.0 || v < 1.0)
            {
                return(0.0);
            }
            return(GammaFunctions.incompleteGammaComplement(v / 2.0, x / 2.0));
        }
        /// <summary>
        /// Returns the sum of the first <tt>k</tt> terms of the Poisson distribution.
        /// <pre>
        ///   k         j
        ///   --   -m  m
        ///   >   e    --
        ///   --       j!
        ///  j=0
        /// </pre>
        /// The terms are not summed directly; instead the incomplete
        /// gamma integral is employed, according to the relation
        /// <para>
        /// <tt>y = poisson( k, m ) = Gamma.incompleteGammaComplement( k+1, m )</tt>.
        ///
        /// The arguments must both be positive.
        ///
        /// </para>
        /// </summary>
        /// <param name="k"> number of terms. </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 poisson(int k, double mean) throws ArithmeticException
        public static double poisson(int k, double mean)
        {
            if (mean < 0)
            {
                throw new System.ArgumentException();
            }
            if (k < 0)
            {
                return(0.0);
            }
            return(GammaFunctions.incompleteGammaComplement((double)(k + 1), mean));
        }