blog.distrib
Class Bernoulli

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

public class Bernoulli
extends AbstractCondProbDistrib

A distribution over Boolean values. It is defined by one parameter, which is the probability of true. This parameter can be specified when the distribution is initialized, in which case the distribution takes no arguments; or the distribution can be initialized with no parameters, in which case it takes the probability as an argument.


Constructor Summary
Bernoulli(double pi)
          Creates a new Bernoulli distribution with the probability of true set to pi.
Bernoulli(java.util.List params)
          Creates a new Bernoulli distribution.
 
Method Summary
 double getLogProb(boolean value)
          Returns the log probability of the given Boolean value under this distribution.
 double getProb(boolean value)
          Returns the probability of the given Boolean value under this distribution.
 double getProb(java.util.List args, java.lang.Object value)
          For a discrete distribution, returns the conditional probability of childValue given the argument values args.
 boolean sampleVal()
          Returns a boolean value sampled from this distribution.
 java.lang.Object sampleVal(java.util.List args, Type childType)
          Samples a value according to this CPD given the args .
 
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

Bernoulli

public Bernoulli(double pi)
Creates a new Bernoulli distribution with the probability of true set to pi.


Bernoulli

public Bernoulli(java.util.List params)
Creates a new Bernoulli distribution. If params is empty, then the distribution takes one CPD argument, which is the probability of true. Otherwise, params should contain one element, a Number specifying this probability.

Method Detail

getProb

public double getProb(boolean value)
Returns the probability of the given Boolean value under this distribution. This method should only be called if this distribution was initialized with a fixed success probability, or if ensureProbsInited has just been called.


getProb

public double getProb(java.util.List args,
                      java.lang.Object value)
Description copied from interface: CondProbDistrib
For a discrete distribution, returns the conditional probability of childValue given the argument values args. For a continuous distribution, returns the conditional probability density at childValue.


getLogProb

public double getLogProb(boolean value)
Returns the log probability of the given Boolean value under this distribution. This method should only be called if this distribution was initialized with a fixed success probability, or if ensureProbsInited has just been called.


sampleVal

public boolean sampleVal()
Returns a boolean value sampled from this distribution. This method should only be called if this distribution was initialized with a fixed success probability, or if ensureProbsInited has just been called.


sampleVal

public java.lang.Object sampleVal(java.util.List args,
                                  Type childType)
Description copied from interface: CondProbDistrib
Samples a value according to this CPD given the args . The object returned should be of the specified type.