blog.distrib
Class BoundedGeometric

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

public class BoundedGeometric
extends AbstractCondProbDistrib

Like a geometric distribution, but with an upper bound B. The value B gets all the probability mass that would ordinarily go to numbers greater than or equal to B. The parameter alpha now denotes P(X >= n+1 | X >= n) only for n < B. The distribution is defined by:

   P(X = n) = (1 - alpha) alpha^n  for n < B
   P(X = B) = alpha^B
 
The alpha value should be given as a parameter, and the upper bound as an argument.


Constructor Summary
BoundedGeometric(java.util.List params)
          Creates a bounded geometric distribution with the given alpha parameter.
 
Method Summary
 double getLogProb(int n)
          Returns the natural log of the probability of the given integer under this distribution.
 double getLogProb(java.util.List args, java.lang.Object value)
          Returns the log probability of the given value, which should be an Integer.
 double getProb(int n)
          Returns the probability of the given integer under this distribution.
 double getProb(java.util.List args, java.lang.Object value)
          Returns the probability of the given value, which should be an Integer.
 java.lang.Object sampleVal(java.util.List args, Type childType)
          Generates a sample from this distribution.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BoundedGeometric

public BoundedGeometric(java.util.List params)
Creates a bounded geometric distribution with the given alpha parameter.

Throws:
java.lang.IllegalArgumentException - if alpha < 0 or alpha > 1.
Method Detail

getProb

public double getProb(int n)
Returns the probability of the given integer under this distribution.


getProb

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


getLogProb

public double getLogProb(int n)
Returns the natural log of the probability of the given integer under this distribution.


getLogProb

public double getLogProb(java.util.List args,
                         java.lang.Object value)
Returns the log probability of the given value, which should be an Integer. Expects no arguments.

Specified by:
getLogProb in interface CondProbDistrib
Overrides:
getLogProb in class AbstractCondProbDistrib

sampleVal

public java.lang.Object sampleVal(java.util.List args,
                                  Type childType)
Generates a sample from this distribution. Expects no arguments.


toString

public java.lang.String toString()
Overrides:
toString in class AbstractCondProbDistrib