org.jscience.mathematics.statistics
Class BinomialRandomNDistribution

java.lang.Object
  extended by org.jscience.mathematics.statistics.Distribution
      extended by org.jscience.mathematics.statistics.BinomialRandomNDistribution

public class BinomialRandomNDistribution
extends Distribution

This class models the binomial distribution with a random number of trials.


Field Summary
 
Fields inherited from class org.jscience.mathematics.statistics.Distribution
CONTINUOUS, DISCRETE, MIXED
 
Constructor Summary
BinomialRandomNDistribution()
          This default constructor creates a new randomized binomial distribution with probability of success 0.5 and the uniform distribution on {1, 2, 3, 4, 5, 6} or the number of trials.
BinomialRandomNDistribution(Distribution d, double p)
          This general constructor creates a new randomized binomial distribution with a specified probability of success and a specified distribution for the number of trials.
BinomialRandomNDistribution(double p)
          This special constructor creates a new randomized binomial distribution with a specified probability of success and the uniform distribution on {1, 2, 3, 4, 5, 6} for the number of trials.
 
Method Summary
 double getDensity(double x)
          This method computes the probability density function in terms of the probability density of the number of trials and the probability of success.
 Distribution getDistribution()
          This method gets the distribution for the number of trials.
 double getMean()
          This method computes the mean in terms of the mean of the number of trials and the probability of success.
 double getMGF(double t)
          This method computes the moment generating funciton in terms of the probability generating function,
 double getPGF(double t)
          This method computes the probability generating function in terms of the probability generating function of the number of trials and the probability of success.
 double getProbability()
          This method returns the probability of success.
 double getVariance()
          This method computes the variance in terms of the mean and variance of the number of trials and the probability of success.
 void setDistribution(Distribution d)
          This method sets the distribution for the number of trials.
 void setParameters(Distribution d, double p)
          This method sets the parameters: the distribution for the number of trials and the probability of success.
 void setProbability(double p)
          This method sets the probability of success.
 double simulate()
          This method simulates a value from the distribution, by simulating a random number of Bernoulli trials and then computing the number of successes.
 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 org.jscience.mathematics.statistics.Distribution
getCDF, getDomain, getFailureRate, getMaxDensity, 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

BinomialRandomNDistribution

public BinomialRandomNDistribution(Distribution d,
                                   double p)
This general constructor creates a new randomized binomial distribution with a specified probability of success and a specified distribution for the number of trials.

Parameters:
d - the distribution of the number of trials
p - the probabiltiy of success

BinomialRandomNDistribution

public BinomialRandomNDistribution(double p)
This special constructor creates a new randomized binomial distribution with a specified probability of success and the uniform distribution on {1, 2, 3, 4, 5, 6} for the number of trials.

Parameters:
p - the probability of success

BinomialRandomNDistribution

public BinomialRandomNDistribution()
This default constructor creates a new randomized binomial distribution with probability of success 0.5 and the uniform distribution on {1, 2, 3, 4, 5, 6} or the number of trials.

Method Detail

setParameters

public void setParameters(Distribution d,
                          double p)
This method sets the parameters: the distribution for the number of trials and the probability of success. Also, the default domain is computed.

Parameters:
d - the distribution of the number of trials
p - the probability of success

setDistribution

public void setDistribution(Distribution d)
This method sets the distribution for the number of trials.

Parameters:
d - the distribution of the number of trials.

getDistribution

public Distribution getDistribution()
This method gets the distribution for the number of trials.

Returns:
the distribution of 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 probability density 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

getMean

public double getMean()
This method computes the mean in terms of the mean 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 mean and variance of the number of trials and the probability of success.

Overrides:
getVariance in class Distribution
Returns:
the variance

getPGF

public double getPGF(double t)
This method computes the probability generating function in terms of the probability generating function 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 funciton in terms of the probability generating function,

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

simulate

public double simulate()
This method simulates a value from the distribution, by simulating a random number of Bernoulli trials and then computing the number of successes.

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

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