numpy geometric vs. pymc geometric (shifted vs. unshifted)

68 views
Skip to first unread message

Jeet Sukumaran

unread,
May 31, 2012, 7:34:30 PM5/31/12
to PyMC
Hi all,

I am just starting to explore using PyMC, and love it so far.

I have a question regarding the geometric distribution used in PyMC
vs. numpy. Am I correct in thinking that both of these are shifted
geometric distributions, i.e., with support {1, 2, ...} and a PMF of:

Pr(k|p) = (1-p)^(k-1) p

and an expectation of:

E[k] = 1/p

?

The documentation for PyMC (http://pymc.googlecode.com/svn/doc/
distributions.html) says that its geometric likelihood (which I assume
underlies its Geometric stochastic class) is also shifted with support
{1,2,...}.

The reason that I ask is that this post describing calculation of
Bayes Factors of a geometric vs. poisson model:

http://stronginference.com/post/bayes-factors-pymc

calculates the probability parameter `p` from the mean `mu` as if the
distribution was unshifted (i.e., with support {0, 1, 2,...}; Pr(k|p)
= (1-p)^(k-1) p; E[k] = E[k] = (1 - p) / p):

p = Lambda('p', lambda mu=mu: 1/(1+mu))

I am trying to replicate this example in a slight different context,
with observed data simulated using `numpy.random.geometric` and was
wondering if the above is correct or whether or not I should actually
be using:

p = Lambda('p', lambda mu=mu: 1/mu)





Chris Fonnesbeck

unread,
Jun 3, 2012, 4:50:16 PM6/3/12
to py...@googlegroups.com
The docs on the googlecode svn repo are outdated. Please refer to the current official docs for all likelihood definitions:


On my Bayes factor blog post, notice that I manually shift the data to confer to the geometric specification in PyMC:

return geometric_like(value+1, p)*(M==0) or poisson_like(value, mu)

Jeet Sukumaran

unread,
Jun 3, 2012, 10:00:11 PM6/3/12
to PyMC
Thanks for the clarification. The example now makes sense to me!
Reply all
Reply to author
Forward
0 new messages