This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import random | |
def crpgen(N = None, alpha = 1.0): | |
""" | |
A generator that implements the Chinese Restaurant Process | |
""" | |
counts = [] | |
n = 0 | |
while N == None or n < N: | |
# Compute the (unnormalized) probabilities of assigning the new object |
NewerOlder