edu.uah.math.distributions
Class BirthdayDistribution

java.lang.Object
  extended by edu.uah.math.distributions.Distribution
      extended by edu.uah.math.distributions.BirthdayDistribution
All Implemented Interfaces:
java.io.Serializable

public class BirthdayDistribution
extends Distribution
implements java.io.Serializable

This class models the distribution of the number of distinct sample values when a sample of a specified size is chosen with replacement from a finite population of a specified size.

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
BirthdayDistribution()
          This default constructor creates a new birthday distribution with population size 365 (the classical birthday problem) and sample size 20.
BirthdayDistribution(int n, int k)
          This general constructor creates a new birthday distribution with a specified population size and sample size.
 
Method Summary
 double getDensity(double x)
          This method computes the probability density function.
 double getMean()
          This method computes the mean of the distribution in terms of the parameters.
 int getPopulationSize()
          This method returns the population size.
 int getSampleSize()
          This method returns the sample size.
 double getVariance()
          This method computes the variance of the distribution in terms of the parameters.
 void setParameters(int n, int k)
          This method sets the parameters: the population size and the sample size.
 void setPopulationSize(int n)
          This method sets the population size.
 void setSampleSize(int k)
          This method sets the sample size.
 double simulate()
          This method simulates 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
getCDF, getDomain, getFailureRate, getMaxDensity, getMedian, getMGF, getMoment, getMoment, getPGF, getQuantile, getSD, getType, setDomain, setDomain
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BirthdayDistribution

public BirthdayDistribution(int n,
                            int k)
This general constructor creates a new birthday distribution with a specified population size and sample size.

Parameters:
n - the population size
k - the sample size

BirthdayDistribution

public BirthdayDistribution()
This default constructor creates a new birthday distribution with population size 365 (the classical birthday problem) and sample size 20.

Method Detail

setParameters

public void setParameters(int n,
                          int k)
This method sets the parameters: the population size and the sample size. Also, the probabilities are computed and stored in an array, and the domain computed.

Parameters:
n - the population size
k - the sample size

getDensity

public double getDensity(double x)
This method computes the probability density function.

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 of the distribution in terms of the parameters.

Overrides:
getMean in class Distribution
Returns:
the mean

getVariance

public double getVariance()
This method computes the variance of the distribution in terms of the parameters.

Overrides:
getVariance in class Distribution
Returns:
the variance

getPopulationSize

public int getPopulationSize()
This method returns the population size.

Returns:
the population size

setPopulationSize

public void setPopulationSize(int n)
This method sets the population size.

Parameters:
n - the population size

getSampleSize

public int getSampleSize()
This method returns the sample size.

Returns:
the sample size

setSampleSize

public void setSampleSize(int k)
This method sets the sample size.

Parameters:
k - the sample size

simulate

public double simulate()
This method simulates a value from the distribution. This is done by simulating a random sample from the population, and computing the number of distinct sample values.

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