edu.uah.math.distributions
Class BinomialDistribution

java.lang.Object
  extended by edu.uah.math.distributions.Distribution
      extended by edu.uah.math.distributions.BinomialDistribution
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
BernoulliDistribution

public class BinomialDistribution
extends Distribution
implements java.io.Serializable

This class models the binomial distribution with a specified number of trials and probability of success. This distribution governs the number of success.

Version:
August, 2003
Author:
Kyle Siegrist, Dawn Duehring
See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.uah.math.distributions.Distribution
CONTINUOUS, DISCRETE, MIXED
 
Constructor Summary
BinomialDistribution()
          This default constructor creates the binomial distribution with 10 trials and probability of success 0.5.
BinomialDistribution(int n, double p)
          This general constructor creates the binomial distribution with a specified number of trials and probabiltiy of success.
 
Method Summary
 double getCDF(double x)
          This method computes the cumulative distribution function in terms of the beta cumulative distribution function.
 double getDensity(double x)
          This method computes the probability density function in terms of the number of trials and the probability of success.
 double getFactorialMoment(int k)
          This method returns the factorial moment of a specified order.
 double getMaxDensity()
          This method returns the maximum value of the density function.
 double getMean()
          This method computes the mean in terms of the number of trials and the probability of success.
 double getMGF(double t)
          This method computes the moment generating function in terms of the probability generating function.
 double getPGF(double t)
          This method computes the probability generating function in terms of the number of trials and the probability of success.
 double getProbability()
          This method returns the probability of success.
 int getTrials()
          This method returns the number of trials.
 double getVariance()
          This method computes the variance in terms of the probability of success and the number of trials.
 void setParameters(int n, double p)
          This method sets the number of trials and the probability of success, and computes the default domain.
 void setProbability(double p)
          This method sets the probability of success.
 void setTrials(int n)
          This method sets the number of trails.
 double simulate()
          This method simulates the a value from the distribution.
 java.lang.String toString()
          This method returns a string that gives the name of the distribution and the values of the parameters.
 
Methods inherited from class edu.uah.math.distributions.Distribution
getDomain, getFailureRate, getMedian, getMoment, getMoment, getQuantile, getSD, getType, setDomain, setDomain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BinomialDistribution

public BinomialDistribution(int n,
                            double p)
This general constructor creates the binomial distribution with a specified number of trials and probabiltiy of success.

Parameters:
n - the number of trials
p - the probability of success

BinomialDistribution

public BinomialDistribution()
This default constructor creates the binomial distribution with 10 trials and probability of success 0.5.

Method Detail

setParameters

public void setParameters(int n,
                          double p)
This method sets the number of trials and the probability of success, and computes the default domain.


setTrials

public void setTrials(int n)
This method sets the number of trails.

Parameters:
n - the number of trials

getTrials

public int getTrials()
This method returns the number of trials.

Returns:
the number of trials

setProbability

public void setProbability(double p)
This method sets the probability of success.

Parameters:
p - the probability of success

getProbability

public double getProbability()
This method returns the probability of success.

Returns:
the probability of success

getDensity

public double getDensity(double x)
This method computes the probability density function in terms of the number of trials and the probability of success.

Specified by:
getDensity in class Distribution
Parameters:
x - a number in the domain of the distribuiton
Returns:
the probability density at x

getMaxDensity

public double getMaxDensity()
This method returns the maximum value of the density function.

Overrides:
getMaxDensity in class Distribution
Returns:
the maximum value of the probability density function

getMean

public double getMean()
This method computes the mean in terms of the number of trials and the probability of success.

Overrides:
getMean in class Distribution
Returns:
the mean

getVariance

public double getVariance()
This method computes the variance in terms of the probability of success and the number of trials.

Overrides:
getVariance in class Distribution
Returns:
the variance

getCDF

public double getCDF(double x)
This method computes the cumulative distribution function in terms of the beta cumulative distribution function.

Overrides:
getCDF in class Distribution
Parameters:
x - a number in the domain of the distribution
Returns:
the cumulative probability at x

simulate

public double simulate()
This method simulates the a value from the distribution. This is done by simulating the Bernoulli trials and counting the number of successes.

Overrides:
simulate in class Distribution
Returns:
a simulated value from the distribution

getPGF

public double getPGF(double t)
This method computes the probability generating function in terms of the number of trials and the probability of success.

Overrides:
getPGF in class Distribution
Parameters:
t - a real number
Returns:
the probability generating function at t

getMGF

public double getMGF(double t)
This method computes the moment generating function in terms of the probability generating function.

Overrides:
getMGF in class Distribution
Parameters:
t - a real number
Returns:
the moment generating function at t

getFactorialMoment

public double getFactorialMoment(int k)
This method returns the factorial moment of a specified order.

Parameters:
k - the order
Returns:
the factorial moment of order k

toString

public java.lang.String toString()
This method returns a string that gives the name of the distribution and the values of the parameters.

Overrides:
toString in class Distribution
Returns:
a string giving the name of the distribution and the values of the parameters