Class SpecFunc


  • public class SpecFunc
    extends Object
    Assorted special functions, primarily concerning probability distributions. For cumBinomial use cern.jet.stat.Probability.binomial.

    Mostly ported from the R source tree (dhyper.c etc.), much due to Catherine Loader.

    Author:
    Paul Pavlidis
    See Also:
    cern.jet.stat.gamma , cern.jet.math.arithmetic
    • Constructor Detail

      • SpecFunc

        public SpecFunc()
    • Method Detail

      • dbinom

        public static double dbinom​(double x,
                                    double n,
                                    double p)
        See dbinom_raw.
        Parameters:
        x - Number of successes
        n - Number of trials
        p - Probability of success
        Returns:
      • dhyper

        public static double dhyper​(int x,
                                    int r,
                                    int b,
                                    int n)
        Ported from R (Catherine Loader)

        DESCRIPTION

        Given a sequence of r successes and b failures, we sample n (\le b+r) items without replacement. The hypergeometric probability is the probability of x successes:

        
                       choose(r, x) * choose(b, n-x)
         (x; r,b,n) =  -----------------------------  =
                             choose(r+b, n)
        
            dbinom(x,r,p) * dbinom(n-x,b,p)
         = --------------------------------
               dbinom(n,r+b,p)
         

        for any p. For numerical stability, we take p=n/(r+b); with this choice, the denominator is not exponentially small.

      • phyper

        public static double phyper​(int x,
                                    int NR,
                                    int NB,
                                    int n,
                                    boolean lowerTail)
        Ported from R phyper.c

        Sample of n balls from NR red and NB black ones; x are red

        Parameters:
        x - - number of reds retrieved == successes
        NR - - number of reds in the urn. == positives
        NB - - number of blacks in the urn == negatives
        n - - the total number of objects drawn == successes + failures
        lowerTail -
        Returns:
        cumulative hypergeometric distribution.
      • trigammaInverse

        public static double trigammaInverse​(double x)
        Parameters:
        x -
        Returns:
      • trigammaInverse

        public static cern.colt.matrix.DoubleMatrix1D trigammaInverse​(cern.colt.matrix.DoubleMatrix1D x)
        Ported from limma
        Parameters:
        x - vector to be operated on
        Returns:
        solution for y: trigamma(y) = x