implement sampling algorithm from Chinese Restaurant Process