org.apache.mahout.math.random
Class ChineseRestaurant

java.lang.Object
  extended by org.apache.mahout.math.random.ChineseRestaurant
All Implemented Interfaces:
Sampler<Integer>

public final class ChineseRestaurant
extends Object
implements Sampler<Integer>

Generates samples from a generalized Chinese restaurant process (or Pittman-Yor process). The number of values drawn exactly once will asymptotically be equal to the discount parameter as the total number of draws T increases without bound. The number of unique values sampled will increase as O(alpha * log T) if discount = 0 or O(alpha * T^discount) for discount > 0.


Constructor Summary
ChineseRestaurant(double alpha)
          Constructs a Dirichlet process sampler.
ChineseRestaurant(double alpha, double discount)
          Constructs a Pitman-Yor sampler.
 
Method Summary
 int count()
           
 int count(int j)
           
 Integer sample()
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChineseRestaurant

public ChineseRestaurant(double alpha)
Constructs a Dirichlet process sampler. This is done by setting discount = 0.

Parameters:
alpha - The strength parameter for the Dirichlet process.

ChineseRestaurant

public ChineseRestaurant(double alpha,
                         double discount)
Constructs a Pitman-Yor sampler.

Parameters:
alpha - The strength parameter that drives the number of unique values as a function of draws.
discount - The discount parameter that drives the percentage of values that occur once in a large sample.
Method Detail

sample

public Integer sample()
Specified by:
sample in interface Sampler<Integer>

size

public int size()
Returns:
the number of unique values that have been returned.

count

public int count()
Returns:
the number draws so far.

count

public int count(int j)
Parameters:
j - Which value to test.
Returns:
The number of times that j has been returned so far.


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.