blog.distrib
Class ChooseFromArgs

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

public class ChooseFromArgs
extends AbstractCondProbDistrib

CPD that takes a sequence of probabilities as parameters, and uses those probabilities to define a distribution over its arguments. The number of arguments must equal the number of probability parameters. Alternatively, a ChooseFromArgs CPD can be constructed with no parameters, in which case it expects a column vector of probabilities as its first argument and chooses from its remaining arguments.


Constructor Summary
ChooseFromArgs(double[] probs)
          Creates a ChooseFromArgs CPD with the given parameter vector.
ChooseFromArgs(java.util.List params)
          Creates a new ChooseFromArgs distribution from the given parameter list.
 
Method Summary
 double getProb(java.util.List args, java.lang.Object childValue)
          Returns the probability of the given child value conditioned on the given argument values.
 java.lang.Object sampleVal(java.util.List args, Type childType)
          Returns a value sampled 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

ChooseFromArgs

public ChooseFromArgs(double[] probs)
Creates a ChooseFromArgs CPD with the given parameter vector.


ChooseFromArgs

public ChooseFromArgs(java.util.List params)
Creates a new ChooseFromArgs distribution from the given parameter list. If the parameter list is empty, then the probability vector must be passed as an argument to this CPD. Otherwise, the parameter list should contain the probability vector as a sequence of Number objects.

Method Detail

getProb

public double getProb(java.util.List args,
                      java.lang.Object childValue)
Returns the probability of the given child value conditioned on the given argument values. If this distribution was constructed with a probability vector, then the arguments are the possible values. Otherwise, the first argument should be a column vector of probabilities and the remaining arguments should be the possible values.

Throws:
java.lang.IllegalArgumentException - if the probability vector was not specified at construction and the first argument is not a column vector of probabilities

sampleVal

public java.lang.Object sampleVal(java.util.List args,
                                  Type childType)
Returns a value sampled according to this distribution. If this distribution was constructed with a probability vector, then the arguments are the possible values. Otherwise, the first argument should be a column vector of probabilities and the remaining arguments should be the possible values.

Throws:
java.lang.IllegalArgumentException - if the probability vector was not specified at construction and the first argument is not a column vector of probabilities