weka.classifiers.misc.monotone
Class DistributionUtils

java.lang.Object
  extended by weka.classifiers.misc.monotone.DistributionUtils
All Implemented Interfaces:
RevisionHandler

public class DistributionUtils
extends java.lang.Object
implements RevisionHandler

Class with some simple methods acting on CumulativeDiscreteDistribution. All of the methods in this class are very easily implemented and the main use of this class is to gather all these methods in a single place. It could be argued that some of the methods should be implemented in the class CumulativeDiscreteDistribution itself.

This implementation is part of the master's thesis: "Studie en implementatie van instantie-gebaseerde algoritmen voor gesuperviseerd rangschikken", Stijn Lievens, Ghent University, 2004.

Version:
$Revision: 1.2 $
Author:
Stijn Lievens (stijn.lievens@ugent.be)

Constructor Summary
DistributionUtils()
           
 
Method Summary
static double[] getDistributionArray(DiscreteEstimator df)
          Converts a DiscreteEstimator to an array of doubles.
static CumulativeDiscreteDistribution getMaximalCumulativeDiscreteDistribution(int numClasses)
          Get the maximal CumulativeDiscreteDistribution over numClasses elements.
static CumulativeDiscreteDistribution getMinimalCumulativeDiscreteDistribution(int numClasses)
          Get the minimal CumulativeDiscreteDistribution over numClasses elements.
 java.lang.String getRevision()
          Returns the revision string.
static CumulativeDiscreteDistribution interpolate(CumulativeDiscreteDistribution cdf1, CumulativeDiscreteDistribution cdf2, double s)
          Compute a linear interpolation between the two given CumulativeDiscreteDistribution.
static CumulativeDiscreteDistribution interpolate(CumulativeDiscreteDistribution cdf1, CumulativeDiscreteDistribution cdf2, double[] s)
          Compute a linear interpolation between the two given CumulativeDiscreteDistribution.
static DiscreteDistribution interpolate(DiscreteDistribution ddf1, DiscreteDistribution ddf2, double s)
          Compute a linear interpolation between the two given DiscreteDistribution.
static CumulativeDiscreteDistribution takeMax(CumulativeDiscreteDistribution cdf1, CumulativeDiscreteDistribution cdf2)
          Create a new CumulativeDiscreteDistribution that is the maximum of the two given CumulativeDiscreteDistribution.
static CumulativeDiscreteDistribution takeMin(CumulativeDiscreteDistribution cdf1, CumulativeDiscreteDistribution cdf2)
          Create a new CumulativeDiscreteDistribution that is the minimum of the two given CumulativeDiscreteDistribution.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DistributionUtils

public DistributionUtils()
Method Detail

interpolate

public static CumulativeDiscreteDistribution interpolate(CumulativeDiscreteDistribution cdf1,
                                                         CumulativeDiscreteDistribution cdf2,
                                                         double s)
                                                  throws java.lang.IllegalArgumentException
Compute a linear interpolation between the two given CumulativeDiscreteDistribution.

Parameters:
cdf1 - the first CumulativeDiscreteDistribution
cdf2 - the second CumulativeDiscreteDistribution
s - the interpolation parameter
Returns:
(1 - s) × cdf1 + s × cdf2
Throws:
java.lang.IllegalArgumentException - if the two distributions don't have the same size or if the parameter s is not in the range [0,1]

interpolate

public static CumulativeDiscreteDistribution interpolate(CumulativeDiscreteDistribution cdf1,
                                                         CumulativeDiscreteDistribution cdf2,
                                                         double[] s)
                                                  throws java.lang.IllegalArgumentException
Compute a linear interpolation between the two given CumulativeDiscreteDistribution.

Parameters:
cdf1 - the first CumulativeDiscreteDistribution
cdf2 - the second CumulativeDiscreteDistribution
s - the interpolation parameters, only the relevant number of entries is used, so the array may be longer than the common length of cdf1 and cdf2
Returns:
(1 - s) × cdf1 + s × cdf2, or more specifically a distribution cd such that cd.getCumulativeProbability(i) = (1-s[i]) × cdf1.getCumulativeProbability(i) + s[i] × cdf2.getCumulativeProbability(i)
Throws:
java.lang.IllegalArgumentException - if the two distributions don't have the same size or if the array s contains parameters not in the range [0,1]

interpolate

public static DiscreteDistribution interpolate(DiscreteDistribution ddf1,
                                               DiscreteDistribution ddf2,
                                               double s)
                                        throws java.lang.IllegalArgumentException
Compute a linear interpolation between the two given DiscreteDistribution.

Parameters:
ddf1 - the first DiscreteDistribution
ddf2 - the second DiscreteDistribution
s - the interpolation parameter
Returns:
(1 - s) × ddf1 + s × ddf2
Throws:
java.lang.IllegalArgumentException - if the two distributions don't have the same size or if the parameter s is not in the range [0,1]

takeMin

public static CumulativeDiscreteDistribution takeMin(CumulativeDiscreteDistribution cdf1,
                                                     CumulativeDiscreteDistribution cdf2)
                                              throws java.lang.IllegalArgumentException
Create a new CumulativeDiscreteDistribution that is the minimum of the two given CumulativeDiscreteDistribution. Each component of the resulting probability distribution is the minimum of the two corresponding components.
Note: despite of its name, the returned cumulative probability distribution dominates both the arguments of this method.

Parameters:
cdf1 - first CumulativeDiscreteDistribution
cdf2 - second CumulativeDiscreteDistribution
Returns:
the minimum of the two distributions
Throws:
java.lang.IllegalArgumentException - if the two distributions dont't have the same length

takeMax

public static CumulativeDiscreteDistribution takeMax(CumulativeDiscreteDistribution cdf1,
                                                     CumulativeDiscreteDistribution cdf2)
                                              throws java.lang.IllegalArgumentException
Create a new CumulativeDiscreteDistribution that is the maximum of the two given CumulativeDiscreteDistribution. Each component of the resulting probability distribution is the maximum of the two corresponding components. Note: despite of its name, the returned cumulative probability distribution is dominated by both the arguments of this method.

Parameters:
cdf1 - first CumulativeDiscreteDistribution
cdf2 - second CumulativeDiscreteDistribution
Returns:
the maximum of the two distributions
Throws:
java.lang.IllegalArgumentException - if the two distributions dont't have the same length

getDistributionArray

public static double[] getDistributionArray(DiscreteEstimator df)
Converts a DiscreteEstimator to an array of doubles.

Parameters:
df - the DiscreteEstimator to be converted
Returns:
an array of doubles representing the DiscreteEstimator

getMinimalCumulativeDiscreteDistribution

public static CumulativeDiscreteDistribution getMinimalCumulativeDiscreteDistribution(int numClasses)
                                                                               throws java.lang.IllegalArgumentException
Get the minimal CumulativeDiscreteDistribution over numClasses elements. This means that a probability of one is assigned to the first element.

Parameters:
numClasses - the number of elements
Returns:
the minimal CumulativeDiscreteDistribution over the requested number of elements
Throws:
java.lang.IllegalArgumentException - if numClasses is smaller or equal than 0

getMaximalCumulativeDiscreteDistribution

public static CumulativeDiscreteDistribution getMaximalCumulativeDiscreteDistribution(int numClasses)
                                                                               throws java.lang.IllegalArgumentException
Get the maximal CumulativeDiscreteDistribution over numClasses elements. This means that a probability of one is assigned to the last class.

Parameters:
numClasses - the number of elements
Returns:
the maximal CumulativeDiscreteDistribution over the requested number of elements
Throws:
java.lang.IllegalArgumentException - if numClasses is smaller or equal than 0

getRevision

public java.lang.String getRevision()
Returns the revision string.

Specified by:
getRevision in interface RevisionHandler
Returns:
the revision