Created
September 23, 2010 16:57
-
-
Save aflaxman/593975 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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).