Class Bernoulli

    • Constructor Detail

      • Bernoulli

        public Bernoulli()
        Constructs a probability distribution, the default is Bernouli(0.5)
      • Bernoulli

        public Bernoulli​(double[] parameters)
        Constructs a probability distribution with the default random number generator,
        Parameters:
        parameters - should be an array with parameter[0]=p
      • Bernoulli

        public Bernoulli​(double prob)
        Constructs a probability distribution with the default random number generator,
        Parameters:
        prob - is the success probability
      • Bernoulli

        public Bernoulli​(double prob,
                         java.lang.String name)
        Constructs a probability distribution with the default random number generator,
        Parameters:
        prob - is the success probability
        name - a string label
    • Method Detail

      • setProbabilityOfSuccess

        public final void setProbabilityOfSuccess​(double prob)
        Sets the success probability
        Parameters:
        prob - The success probability
      • getProbabilityOfSuccess

        public final double getProbabilityOfSuccess()
        Gets the success probability
        Returns:
        The success probability
      • cdf

        public final double cdf​(double xx)
        Returns the P(X<=x)
        Specified by:
        cdf in interface CDFIfc
        Parameters:
        xx - The value we want the cumulative probability up to
        Returns:
        The cumulative probability
      • invCDF

        public final double invCDF​(double prob)
        Returns the value of x such that p = Pr{X <= x} where F represents the cumulative distribution function
        Specified by:
        invCDF in interface InverseCDFIfc
        Parameters:
        prob - a double representing the probability
        Returns:
        a double representing the bernoulli variate
      • getMean

        public final double getMean()
        Returns the mean of the distribution if defined
        Specified by:
        getMean in interface MeanIfc
        Returns:
        double the mean or expected value for the distribution
      • pmf

        public final double pmf​(double x)
        Returns the f(x) where f represents the probability mass function for the distribution. If JSLMath.equal(x,1.0) the probability of success is returned If JSLMath.equal(x,0.0) the probability of failure is returned otherwise 0.0 is returned.
        Specified by:
        pmf in interface PMFIfc
        Parameters:
        x - a double representing the value to be evaluated
        Returns:
        f(x)
      • pmf

        public final double pmf​(int x)
        Returns the f(x) where f represents the probability mass function for the distribution.
        Parameters:
        x - an int representing the value to be evaluated
        Returns:
        f(x)
      • getVariance

        public final double getVariance()
        Returns the variance of the random variate if defined
        Specified by:
        getVariance in interface VarianceIfc
        Returns:
        double the variance of the random variable
      • setParameters

        public final void setParameters​(double[] parameters)
        Sets the parameters for the distribution
        Specified by:
        setParameters in interface ParametersIfc
        Parameters:
        parameters - an array of doubles representing the parameters for the distribution
      • getParameters

        public final double[] getParameters()
        Gets the parameters for the distribution
        Specified by:
        getParameters in interface ParametersIfc
        Returns:
        Returns an array of the parameters for the distribution