de.unidu.is.statistics
Class DiscreteDistribution

java.lang.Object
  extended byde.unidu.is.statistics.Distribution
      extended byde.unidu.is.statistics.DiscreteDistribution

public class DiscreteDistribution
extends Distribution

An class modelling discrete (empirical) probabilistic distributions.

The original values from which the distribution is derived are sorted into bins of equal size. The first bin starts at the minimum value, the last one at the maximum value. This allows for using this distribution for plotting.

If the distribution should be used for computing actual values, the original values are used.

Since:
2002-04-09
Version:
$Revision: 1.4 $, $Date: 2005/02/21 17:29:27 $
Author:
Henrik Nottelmann

Field Summary
protected  double max
          Maximum original value.
protected  double max2
          Maximum original value s.th. the integral from 0 to this value if less than 0.999.
protected  double min
          Minimum original value.
protected static int parts
          Number of bins minus 1.
protected  double[] values
          Original values from which the distribution is derived.
protected  double[] x
          The x values (bin starting points) of the distribution when plotted.
protected  double[] y
          The y values (bin frequencies) of the distribution when plotted.
 
Constructor Summary
DiscreteDistribution(double[] values)
          Constructs a new distribution, based on the specified original values.
 
Method Summary
 void computeValues(int num, double[] ret)
          Computes actual values based on the underlying distribution when having the specified number of items, and writes them in decreasing order into the specified array (as many values as possible).
 void eliminateZero()
          Eliminates info about the distribution at zero.
 double getMax()
          Returns the maximum original value.
 double getMin()
          Returns the minimum original value.
 double[] getX()
          Returns an array with the x values (bin starting points) of the distribution when plotted.
 double[] getY()
          Returns an array with the y values (bin frequencies) of the distribution when plotted.
 
Methods inherited from class de.unidu.is.statistics.Distribution
computeValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

protected double[] x
The x values (bin starting points) of the distribution when plotted.


y

protected double[] y
The y values (bin frequencies) of the distribution when plotted.


parts

protected static final int parts
Number of bins minus 1.

See Also:
Constant Field Values

values

protected double[] values
Original values from which the distribution is derived.


min

protected double min
Minimum original value.


max

protected double max
Maximum original value.


max2

protected double max2
Maximum original value s.th. the integral from 0 to this value if less than 0.999.

Constructor Detail

DiscreteDistribution

public DiscreteDistribution(double[] values)
Constructs a new distribution, based on the specified original values.

This constructor also creates the bins. The first bin starts at min, the last one at max.

Parameters:
values - original values from which the distribution is derived
Method Detail

getX

public double[] getX()
Returns an array with the x values (bin starting points) of the distribution when plotted.

Returns:
array with the x values (bin starting points)

getY

public double[] getY()
Returns an array with the y values (bin frequencies) of the distribution when plotted.

Returns:
array with the y values (bin frequencies)

getMin

public double getMin()
Returns the minimum original value.

Returns:
minimum original value

getMax

public double getMax()
Returns the maximum original value.

Returns:
maximum original value

eliminateZero

public void eliminateZero()
Eliminates info about the distribution at zero. This is only useful for discrete distributions with a high peak at zero, as then a plot might look better.

Overrides:
eliminateZero in class Distribution

computeValues

public void computeValues(int num,
                          double[] ret)
Computes actual values based on the underlying distribution when having the specified number of items, and writes them in decreasing order into the specified array (as many values as possible).

This method uses the original values and repeates them num/values.lentgh times. Thus, num >= values.lentgh must hold!

Specified by:
computeValues in class Distribution
Parameters:
num - number of items in total
ret - array for the actual values