Class BinomialTest


  • public final class BinomialTest
    extends Object
    Implements binomial test statistics.

    Performs an exact test for the statistical significance of deviations from a theoretically expected distribution of observations into two categories.

    Since:
    1.1
    See Also:
    Binomial test (Wikipedia)
    • Method Detail

      • test

        public SignificanceResult test​(int numberOfTrials,
                                       int numberOfSuccesses,
                                       double probability)
        Performs a binomial test about the probability of success π.

        The null hypothesis is H0:π=π0 where π0 is between 0 and 1.

        The probability of observing k successes from n trials with a given probability of success p is:

        Pr(X=k)=(nk)pk(1p)nk

        The test is defined by the AlternativeHypothesis.

        To test π<π0 (less than):

        p=i=0kPr(X=i)=i=0k(ni)π0i(1π0)ni

        To test π>π0 (greater than):

        p=i=0kPr(X=i)=i=kn(ni)π0i(1π0)ni

        To test ππ0 (two-sided) requires finding all i such that I={i:Pr(X=i)Pr(X=k)} and compute the sum:

        p=iIPr(X=i)=iI(ni)π0i(1π0)ni

        The two-sided p-value represents the likelihood of getting a result at least as extreme as the sample, given the provided probability of success on a single trial.

        The test statistic is equal to the estimated proportion kn.

        Parameters:
        numberOfTrials - Number of trials performed.
        numberOfSuccesses - Number of successes observed.
        probability - Assumed probability of a single trial under the null hypothesis.
        Returns:
        test result
        Throws:
        IllegalArgumentException - if numberOfTrials or numberOfSuccesses is negative; probability is not between 0 and 1; or if numberOfTrials < numberOfSuccesses
        See Also:
        with(AlternativeHypothesis)