be.ac.ulg.montefiore.run.jahmm
Class OpdfDiscrete<E extends java.lang.Enum<E>>

java.lang.Object
  extended by be.ac.ulg.montefiore.run.jahmm.OpdfDiscrete<E>
All Implemented Interfaces:
Opdf<ObservationDiscrete<E>>, java.io.Serializable, java.lang.Cloneable

public class OpdfDiscrete<E extends java.lang.Enum<E>>
extends java.lang.Object
implements Opdf<ObservationDiscrete<E>>

This class implements a distribution over a finite set of elements. This set is implemented as an enum.

See Also:
Serialized Form

Field Summary
protected  OpdfInteger distribution
           
protected  java.util.EnumMap<E,ObservationInteger> toIntegerMap
           
protected  java.util.List<E> values
           
 
Constructor Summary
OpdfDiscrete(java.lang.Class<E> valuesClass)
          Builds a new probability distribution which operates on a finite set of values.
OpdfDiscrete(java.lang.Class<E> valuesClass, double[] probabilities)
          Builds a new probability distribution which operates on integer values.
 
Method Summary
 OpdfDiscrete<E> clone()
           
 void fit(java.util.Collection<? extends ObservationDiscrete<E>> co)
          Fits this observation probability (distribution) function to a (non empty) set of observations.
 void fit(java.util.Collection<? extends ObservationDiscrete<E>> co, double[] weights)
          Fits this observation probability (distribution) function to a weighted (non empty) set of observations.
 void fit(ObservationDiscrete<E>... oa)
          Fits this observation probability (distribution) function to a (non empty) set of observations.
 void fit(ObservationDiscrete<E>[] o, double[] weights)
          Fits this observation probability (distribution) function to a weighted (non empty) set of observations.
 ObservationDiscrete<E> generate()
          Generates a (pseudo) random observation according to this distribution.
 double probability(ObservationDiscrete o)
          Returns the probability (density) of an observation given a distribution.
 java.lang.String toString()
           
 java.lang.String toString(java.text.NumberFormat numberFormat)
          Returns a String describing this distribution.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

distribution

protected OpdfInteger distribution

values

protected final java.util.List<E extends java.lang.Enum<E>> values

toIntegerMap

protected final java.util.EnumMap<E extends java.lang.Enum<E>,ObservationInteger> toIntegerMap
Constructor Detail

OpdfDiscrete

public OpdfDiscrete(java.lang.Class<E> valuesClass)
Builds a new probability distribution which operates on a finite set of values. The probabilities are initialized so that the distribution is uniformaly distributed.

Parameters:
valuesClass - An Enum class representing the set of values.

OpdfDiscrete

public OpdfDiscrete(java.lang.Class<E> valuesClass,
                    double[] probabilities)
Builds a new probability distribution which operates on integer values.

Parameters:
valuesClass - An Enum class representing the set of values.
probabilities - Array holding one probability for each possible value (i.e. such that probabilities[i] is the probability of the observation ith element of values.
Method Detail

probability

public double probability(ObservationDiscrete o)
Description copied from interface: Opdf
Returns the probability (density) of an observation given a distribution.

Specified by:
probability in interface Opdf<ObservationDiscrete<E extends java.lang.Enum<E>>>
Parameters:
o - An observation.
Returns:
The probability (density, if o takes continuous values) of o for this function.

generate

public ObservationDiscrete<E> generate()
Description copied from interface: Opdf
Generates a (pseudo) random observation according to this distribution.

Specified by:
generate in interface Opdf<ObservationDiscrete<E extends java.lang.Enum<E>>>
Returns:
An observation.

fit

public void fit(ObservationDiscrete<E>... oa)
Description copied from interface: Opdf
Fits this observation probability (distribution) function to a (non empty) set of observations. The meaning to give to fits should be has the maximum likelihood if possible.

Specified by:
fit in interface Opdf<ObservationDiscrete<E extends java.lang.Enum<E>>>
Parameters:
oa - An array of observations compatible with this function.

fit

public void fit(java.util.Collection<? extends ObservationDiscrete<E>> co)
Description copied from interface: Opdf
Fits this observation probability (distribution) function to a (non empty) set of observations. The meaning to give to fits should be has the maximum likelihood if possible.

Specified by:
fit in interface Opdf<ObservationDiscrete<E extends java.lang.Enum<E>>>
Parameters:
co - A set of observations compatible with this function.

fit

public void fit(ObservationDiscrete<E>[] o,
                double[] weights)
Description copied from interface: Opdf
Fits this observation probability (distribution) function to a weighted (non empty) set of observations. Equations (53) and (54) of Rabiner's A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition explain how the weights can be used.

Specified by:
fit in interface Opdf<ObservationDiscrete<E extends java.lang.Enum<E>>>
Parameters:
o - An array of observations compatible with this factory.
weights - The weight associated to each observation (such that weight.length == o.length and the sum of all the elements equals 1).

fit

public void fit(java.util.Collection<? extends ObservationDiscrete<E>> co,
                double[] weights)
Description copied from interface: Opdf
Fits this observation probability (distribution) function to a weighted (non empty) set of observations. Equations (53) and (54) of Rabiner's A Tutorial on Hidden Markov Models and Selected Applications in Speech Recognition explain how the weights can be used.

Specified by:
fit in interface Opdf<ObservationDiscrete<E extends java.lang.Enum<E>>>
Parameters:
co - A set of observations compatible with this factory.
weights - The weight associated to each observation (such that weight.length == o.length and the sum of all the elements equals 1).

clone

public OpdfDiscrete<E> clone()
Specified by:
clone in interface Opdf<ObservationDiscrete<E extends java.lang.Enum<E>>>
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(java.text.NumberFormat numberFormat)
Description copied from interface: Opdf
Returns a String describing this distribution.

Specified by:
toString in interface Opdf<ObservationDiscrete<E extends java.lang.Enum<E>>>
Parameters:
numberFormat - A formatter used to convert the numbers (e.g. probabilities) to strings.
Returns:
A String describing this distribution.


Copyright © 2004,2005 Jean-Marc François.