Class DistBinomial

    • Constructor Detail

      • DistBinomial

        public DistBinomial​(StreamInterface stream,
                            int n,
                            double p)
        constructs a Binomial distribution. It calculates the probability for a number of successes in n independent Bernoulli trials with probability p of success on each trial.
        Parameters:
        stream - StreamInterface; the random number stream
        n - long; the number of independent experiments for the Binomial distribution
        p - double; the probability of success for each individual trial in the binomial distribution
        Throws:
        IllegalArgumentException - when n <= 0 or p <= 0 or p >= 1
    • Method Detail

      • draw

        public long draw()
        draws the next long from the stream.
        Specified by:
        draw in class DistDiscrete
        Returns:
        long
      • probability

        public double probability​(long observation)
        returns the probability of the observation in this particular distribution.
        Specified by:
        probability in class DistDiscrete
        Parameters:
        observation - long; the discrete observation.
        Returns:
        double the probability.
      • getN

        public int getN()
        Return the number of independent experiments for the Binomial distribution.
        Returns:
        int; the number of independent experiments for the Binomial distribution
      • getP

        public double getP()
        Return the probability of success for each individual trial in the binomial distribution.
        Returns:
        double; the probability of success for each individual trial in the binomial distribution