blog.distrib
Class RoundedLogNormal

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

public class RoundedLogNormal
extends AbstractCondProbDistrib

Distribution over positive integers for a random variable X = round(Y), where Y has a log normal distribution. This means Z = log(Y) has a normal distribution. A RoundedLogNormal has two parameters, the mean and the variance. For consistency with Hanna's code, we use the mean of Y and the variance of Z.


Constructor Summary
RoundedLogNormal(double mean, double varianceOfLog)
          Creates a RoundedLogNormal distribution where Y has the given mean and log(Y) has the given variance.
RoundedLogNormal(java.util.List params)
          Creates a RoundedLogNormal distribution with the given parameters.
 
Method Summary
 double getLogProb(int n)
          Returns the log probability that X=n.
 double getLogProb(java.util.List args, java.lang.Object value)
          Returns the log probability of the given value under this distribution.
 double getProb(java.util.List args, java.lang.Object value)
          Returns the probability of the given value under 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
toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RoundedLogNormal

public RoundedLogNormal(double mean,
                        double varianceOfLog)
Creates a RoundedLogNormal distribution where Y has the given mean and log(Y) has the given variance.


RoundedLogNormal

public RoundedLogNormal(java.util.List params)
Creates a RoundedLogNormal distribution with the given parameters. This method expects two parameters of class Number, namely the mean of Y and the variance of log(Y).

Method Detail

getProb

public double getProb(java.util.List args,
                      java.lang.Object value)
Returns the probability of the given value under this distribution. Expects no arguments.


getLogProb

public double getLogProb(java.util.List args,
                         java.lang.Object value)
Returns the log probability of the given value under this distribution. Expects no arguments.

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

getLogProb

public double getLogProb(int n)
Returns the log probability that X=n. Note that X gets the value n if Y is between n - 0.5 and n + 0.5, which means Z is between log(n - 0.5) and log(n + 0.5). So we should integrate the density of Z between those two values. To avoid computing the integral, we approximate this by taking the density of Z at log(n) and multiplying it by log(n + 0.5) - log(n - 0.5).


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.