implemented dynamic gamma poisson algorithm