blog.distrib
Class UniformInt

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

public class UniformInt
extends AbstractCondProbDistrib

Uniform distribution over a range of integers. This distribution has two parameters: the lower end of the range and the upper end of the range. The range is inclusive (it includes the upper and lower ends).


Constructor Summary
UniformInt(java.util.List params)
          Interprets the parameters as a pair of integers (lower, upper) and creates a uniform distribution over the range {lower, ..., upper}.
 
Method Summary
 double getProb(java.util.List args, java.lang.Object value)
          Returns 1 / (upper - lower + 1) if the given integer is in the range of this distribution, otherwise returns zero.
 java.lang.Object sampleVal(java.util.List args, Type childType)
          Returns a sample from 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

UniformInt

public UniformInt(java.util.List params)
Interprets the parameters as a pair of integers (lower, upper) and creates a uniform distribution over the range {lower, ..., upper}.

Throws:
java.lang.IllegalArgumentException - if params does not consist of exactly two Integer objects, or if lower > upper
Method Detail

getProb

public double getProb(java.util.List args,
                      java.lang.Object value)
Returns 1 / (upper - lower + 1) if the given integer is in the range of this distribution, otherwise returns zero. Takes no arguments.

Throws:
java.lang.IllegalArgumentException - if args is non-empty or value is not an Integer

sampleVal

public java.lang.Object sampleVal(java.util.List args,
                                  Type childType)
Returns a sample from this distribution.

Throws:
java.lang.IllegalArgumentException - if args is non-empty