blog.distrib
Class UniformChoice

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

public class UniformChoice
extends AbstractCondProbDistrib

CPD that takes a set of objects (an instance of the ObjectSet interface) as an argument, and defines a uniform distribution over this set.


Constructor Summary
UniformChoice()
          Creates a UniformChoice CPD.
UniformChoice(java.util.List params)
          Creates a UniformChoice CPD.
 
Method Summary
 double getProb(java.util.List args, java.lang.Object value)
          Takes a single argument, namely a set S.
 java.lang.Object sampleVal(java.util.List args, Type childType)
          Takes a single argument, namely a finite set S.
 
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

UniformChoice

public UniformChoice()
Creates a UniformChoice CPD. This constructor is not used by the parser, which looks for a constructor taking a List as an argument. Instead, it's used when we create a UniformChoice CPD in the program.


UniformChoice

public UniformChoice(java.util.List params)
Creates a UniformChoice CPD. The CPD takes no parameters.

Throws:
java.lang.IllegalArgumentException - if params is non-empty
Method Detail

getProb

public double getProb(java.util.List args,
                      java.lang.Object value)
Takes a single argument, namely a set S. If S is non-empty, returns 1 / |S| if value is in S, and otherwise 0. If S is empty, returns 1 if the value is Model.NULL, and 0 otherwise.

Throws:
java.lang.IllegalArgumentException - if args contains anything other than a single argument of class ObjectSet.

sampleVal

public java.lang.Object sampleVal(java.util.List args,
                                  Type childType)
Takes a single argument, namely a finite set S. Returns an element of S selected uniformly at random. If S is empty, returns Model.NULL.

Throws:
java.lang.IllegalArgumentException - if args contains anything other than a single argument of class ObjectSet.