Skip to content

Instantly share code, notes, and snippets.

@alextp
Created August 22, 2010 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alextp/544250 to your computer and use it in GitHub Desktop.
Save alextp/544250 to your computer and use it in GitHub Desktop.
def single_collapsed_likelihood(tprior, gmean, gvar, tcount):
"Assumes tprior is a scalar"
p0 = np.log(gamma_pdf(tprior, gmean, gvar))
p0 += tcount.shape[0]*(gammaln(tprior*tcount.shape[1])-gammaln(tprior)*tcount.shape[1])
for d in xrange(tcount.shape[0]):
for i,t in enumerate(tcount[d]):
p0 += gammaln(t + tprior)
p0 -= gammaln(sum(tcount[d]) + tprior*tcount.shape[1])
return p0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment