edu.uah.math.distributions
Class FiniteDistribution

java.lang.Object
  extended by edu.uah.math.distributions.Distribution
      extended by edu.uah.math.distributions.FiniteDistribution
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
DieDistribution, DiscreteUniformDistribution

public class FiniteDistribution
extends Distribution
implements java.io.Serializable

This class models a basic discrete distribution on a finite set of points, with specified probabilities.

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
FiniteDistribution()
          This special constructor creates a new uniform distribution on {1, 2..., 6}.
FiniteDistribution(double a, double b, double w)
          This special constructor creates the uniform distribuiton on the finite set of points.
FiniteDistribution(double a, double b, double w, double[] p)
          This general constructor creates a new finite distribution on a finite set of points with a specified array of probabilities.
 
Method Summary
 double getDensity(double x)
          This method computes the probability density function.
 double getLowerValue()
          This method returns the lower value.
 double[] getProbabilities()
          This method gets the entire array of probabilities.
 double getProbabilities(int i)
          This method gets the probability for a specified index.
 int getSize()
          This method returns the size (the number of values).
 double getUpperValue()
          This method returns the lower value.
 double getWidth()
          This method returns the width.
 void setLowerValue(double a)
          This method sets the lower value.
 void setParameters(double a, double b, double w)
          This method sets the domain parameters.
 void setParameters(double a, double b, double w, double[] p)
          This method sets the parameters: the domain and the probabilities.
 void setProbabilities(double[] p)
          This method sets the probabilities.
 void setProbabilities(int i, double p)
          This method sets an individual probability.
 void setUpperValue(double b)
          This method sets the upper value.
 void setWidth(double w)
          This method sets the step size.
 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, getMean, getMedian, getMGF, getMoment, getMoment, getPGF, getQuantile, getSD, getType, getVariance, setDomain, setDomain, simulate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FiniteDistribution

public FiniteDistribution(double a,
                          double b,
                          double w,
                          double[] p)
This general constructor creates a new finite distribution on a finite set of points with a specified array of probabilities.

Parameters:
a - the lower value of the domain
b - the upper value of the domain
w - the step size of the domain
p - the array of probabilities

FiniteDistribution

public FiniteDistribution(double a,
                          double b,
                          double w)
This special constructor creates the uniform distribuiton on the finite set of points.

Parameters:
a - the lower value of the domain
b - the upper value of the domain
w - the step size of the domain

FiniteDistribution

public FiniteDistribution()
This special constructor creates a new uniform distribution on {1, 2..., 6}.

Method Detail

setParameters

public void setParameters(double a,
                          double b,
                          double w,
                          double[] p)
This method sets the parameters: the domain and the probabilities.

Parameters:
a - the lower value of the domain
b - the upper value of the domain
w - the step size of the domain
p - the array of probabilities

setParameters

public void setParameters(double a,
                          double b,
                          double w)
This method sets the domain parameters. The probability array corresponds to the uniform distribution.

Parameters:
a - the lower value of the domain
b - the upper value of the domain
w - the step size of the domain

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

setProbabilities

public void setProbabilities(double[] p)
This method sets the probabilities. Error correction is performed to ensure that the probabilities are nonnegative and sum to 1.

Parameters:
p - the array of probabilities

setProbabilities

public void setProbabilities(int i,
                             double p)
This method sets an individual probability. The other probabilities would be rescaled appropriately, so that the sum is still 1.

Parameters:
i - the index
p - the probability

getProbabilities

public double getProbabilities(int i)
This method gets the probability for a specified index.

Parameters:
i - the index
Returns:
the probability associated with the index

getProbabilities

public double[] getProbabilities()
This method gets the entire array of probabilities.

Returns:
the array of probabilities

setLowerValue

public void setLowerValue(double a)
This method sets the lower value.

Parameters:
a - the lower value

getLowerValue

public double getLowerValue()
This method returns the lower value.

Returns:
the lower value

setUpperValue

public void setUpperValue(double b)
This method sets the upper value.

Parameters:
b - the upper value

getUpperValue

public double getUpperValue()
This method returns the lower value.

Returns:
the lower value

setWidth

public void setWidth(double w)
This method sets the step size.

Parameters:
w - the width

getWidth

public double getWidth()
This method returns the width.

Returns:
the width

getSize

public int getSize()
This method returns the size (the number of values).

Returns:
the number of values

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