blog.distrib
Class CharDistrib

java.lang.Object
  extended by blog.AbstractCondProbDistrib
      extended by blog.distrib.CharDistrib
All Implemented Interfaces:
CondProbDistrib

public class CharDistrib
extends AbstractCondProbDistrib

A mixture between a multinomial distribution over a fixed set of characters (called the enumerated characters), and a uniform distribution over all characters (i.e., all unsigned 16-bit numbers).


Constructor Summary
CharDistrib(char[] enumChars, double uniformWeight)
          Creates a new CharDistrib with the given enumerated characters and the given weight on the uniform distribution.
CharDistrib(char[] enumChars, double[] pi, double uniformWeight)
          Creates a new CharDistrib with the given enumerated characters, the given distribution over the enumerated characters, and the given weight on the uniform distribution.
CharDistrib(java.util.List params)
          Creates a new CharDistrib with the given parameters.
 
Method Summary
 double getLogProb(char c)
          Returns the log probability of the given character.
 double getProb(char c)
          Returns the probability of the given character.
 double getProb(java.util.List args, java.lang.Object childValue)
          Returns the probability of the given value, which should be of class Character.
 char sampleVal()
          Returns a character selected randomly according to this distribution.
 java.lang.Object sampleVal(java.util.List args, Type childType)
          Returns a Character object sampled randomly according to this distribution.
 
Methods inherited from class blog.AbstractCondProbDistrib
getLogProb, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CharDistrib

public CharDistrib(char[] enumChars,
                   double uniformWeight)
Creates a new CharDistrib with the given enumerated characters and the given weight on the uniform distribution. The distribution over the enumerated characters is uniform.


CharDistrib

public CharDistrib(char[] enumChars,
                   double[] pi,
                   double uniformWeight)
Creates a new CharDistrib with the given enumerated characters, the given distribution over the enumerated characters, and the given weight on the uniform distribution.


CharDistrib

public CharDistrib(java.util.List params)
Creates a new CharDistrib with the given parameters. A CharDistrib expects three parameters:
  1. A string consisting of the enumerated characters;
  2. A 1xN or Nx1 matrix specifying the probability of each enumerated character (where N is the number of enumerated characters);
  3. The mixture weight on the uniform distribution (as a Number).

Method Detail

getProb

public double getProb(char c)
Returns the probability of the given character.


getProb

public double getProb(java.util.List args,
                      java.lang.Object childValue)
Returns the probability of the given value, which should be of class Character. Expects no arguments.


getLogProb

public double getLogProb(char c)
Returns the log probability of the given character.


sampleVal

public char sampleVal()
Returns a character selected randomly according to this distribution.


sampleVal

public java.lang.Object sampleVal(java.util.List args,
                                  Type childType)
Returns a Character object sampled randomly according to this distribution. Expects no arguments.