Skip to content

Instantly share code, notes, and snippets.

@aflaxman
Created September 23, 2010 16:57
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 aflaxman/593975 to your computer and use it in GitHub Desktop.
Save aflaxman/593975 to your computer and use it in GitHub Desktop.
from pymc import *
def test(a0, b0):
# use non-informative priors
x = rbinomial(10, .5, 10)
a = Uniform('a', lower=-1000, upper=1000, value=a0)
b = Normal('b', mu=0, tau=.01, value=b0)
@deterministic
def theta(a=a, b=b):
return a + b * x
p = InvLogit('p', theta)
b = Binomial('b', n=10, p=p, value=x, observed=True) #, verbose=True)
test(.5, 0) # always works
test(.5, None) # sometimes works
test(None, .5) # sometimes works
test(None, None) # almost never works
@fonnesbeck
Copy link

Not too surprising, right? Anything larger (smaller) than 5 (-5) on the nominal scale will be at the boundaries of p. So, positive values of x will result in a ZeroProbabilityError for p=0 (and similarly for p=0 when x<n).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment