Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weka.classifiers.misc.monotone
Class DiscreteDistribution

    java.lang.Object
      weka.classifiers.misc.monotone.DiscreteDistribution

All Implemented Interfaces:
  java.io.Serializable, RevisionHandler

    public class DiscreteDistribution

extends java.lang.Object
implements java.io.Serializable, RevisionHandler

This class represents a discrete probability distribution over a finite number of values.

In the present implementation, objects of type `DiscreteDistribution` are in fact immutable, so all one can do is create objects and retrieve information, such as median and mean, from them.

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: 5922 $
Author:
  Stijn Lievens (stijn.lievens@ugent.be)
See Also:
  Serialized Form

Constructor Summary
`DiscreteDistribution(CumulativeDiscreteDistribution cdf)` Create a `DiscreteDistribution` based on a `CumulativeDiscreteDistribution.`
`DiscreteDistribution(DiscreteEstimator e)` Create a `DiscreteDistribution` based on a `DiscreteEstimator.`
`DiscreteDistribution(double[] dd)` Create a `DiscreteDistribution` based on an array of doubles.

Method Summary
`int` | `getNumSymbols()` Get the number of elements over which the `DiscreteDistribution` is defined.
`double` | `getProbability(int index)` Get the probability of finding the element at a specified index.
`java.lang.String` | `getRevision()` Returns the revision string.
`double` | `mean()` Calculate the mean of the distribution.
`double` | `median()` Calculate the median of the distribution.
`int[]` | `modes()` Get a sorted array containing the indices of the elements with maximal probability.
`boolean` | `stochasticDominatedBy(DiscreteDistribution dd)` Checks if `this` is dominated by `dd.`
`double[]` | `toArray()` Convert the `DiscreteDistribution` to an array of doubles.
`java.lang.String` | `toString()` Get a string representation of the given `DiscreteDistribution.`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### DiscreteDistribution

    public DiscreteDistribution(DiscreteEstimator e)

  Create a `DiscreteDistribution` based on a `DiscreteEstimator.`

  Parameters:
    `e` - the `DiscreteEstimator`

### DiscreteDistribution

    public DiscreteDistribution(CumulativeDiscreteDistribution cdf)

  Create a `DiscreteDistribution` based on a `CumulativeDiscreteDistribution.`

  Parameters:
    `cdf` - the `CumulativeDiscreteDistribution`

### DiscreteDistribution

    public DiscreteDistribution(double[] dd)
                         throws java.lang.IllegalArgumentException

  Create a `DiscreteDistribution` based on an array of doubles.

  Parameters:
    `dd` - the array of doubles representing a valid discrete distribution
  Throws:
    `java.lang.IllegalArgumentException` - if `dd` does not represent a valid discrete distribution

Method Detail

### getNumSymbols

    public int getNumSymbols()

  Get the number of elements over which the `DiscreteDistribution` is defined.

  Returns:
    the number of elements over which the `DiscreteDistribution` is defined

### getProbability

    public double getProbability(int index)

  Get the probability of finding the element at a specified index.

  Parameters:
    `index` - the index of the required element
  Returns:
    the probability of finding the specified element

### mean

    public double mean()

  Calculate the mean of the distribution. The scores for calculating the mean start from 0 and have step size one, i.e. if there are n elements then the scores are 0,1,...,n-1.

  Returns:
    the mean of the distribution

### median

    public double median()

  Calculate the median of the distribution. This means the following: if there is a label m such that P(x <= m) >= ½ and P(x >= m) >= ½ then this label is returned. If there is no such label, an interpolation between the smallest label satisfying the first condition and the largest label satisfying the second condition is performed. The returned value is thus either an element label, or exactly between two element labels.

  Returns:
    the median of the distribution.

### modes

    public int[] modes()

  Get a sorted array containing the indices of the elements with maximal probability.

  Returns:
    an array of class indices with maximal probability.

### toArray

    public double[] toArray()

  Convert the `DiscreteDistribution` to an array of doubles.

  Returns:
    an array of doubles representing the `DiscreteDistribution`

### toString

    public java.lang.String toString()

  Get a string representation of the given `DiscreteDistribution.`

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    a string representation of this object

### stochasticDominatedBy

    public boolean stochasticDominatedBy(DiscreteDistribution dd)
                                  throws java.lang.IllegalArgumentException

  Checks if `this` is dominated by `dd.`

  Parameters:
    `dd` - the DiscreteDistribution to compare to
  Returns:
    `true` if `this` is dominated by `dd` , `false` otherwise
  Throws:
    `java.lang.IllegalArgumentException` - if the two distributions don't have the same length

### getRevision

    public java.lang.String getRevision()

  Returns the revision string.

  Specified by:
    `getRevision` in interface `RevisionHandler`
  Returns:
    the revision

Overview | Package | Class | Tree | Deprecated | Index | Help | Weka's home
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD