https://github.com/pymc-devs/pymc3
Tip revision: 63eba59fe2c42c936136b24babf6ca1e3a777d74 authored by Chris Fonnesbeck on 10 August 2020, 10:48:54 UTC
Fixed error message referencing non-existent file (#4039)
Fixed error message referencing non-existent file (#4039)
Tip revision: 63eba59
gelman_bioassay.py
import pymc3 as pm
from numpy import ones, array
# Samples for each dose level
n = 5 * ones(4, dtype=int)
# Log-dose
dose = array([-.86, -.3, -.05, .73])
with pm.Model() as model:
# Logit-linear model parameters
alpha = pm.Normal('alpha', 0, sigma=100.)
beta = pm.Normal('beta', 0, sigma=1.)
# Calculate probabilities of death
theta = pm.Deterministic('theta', pm.math.invlogit(alpha + beta * dose))
# Data likelihood
deaths = pm.Binomial('deaths', n=n, p=theta, observed=[0, 1, 3, 5])
def run(n=1000):
if n == "short":
n = 50
with model:
pm.sample(n, tune=1000)
if __name__ == '__main__':
run()