Skip to content

Instantly share code, notes, and snippets.

@etheriqa
Created April 2, 2015 16:16
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 etheriqa/89233cbf7657e4f9870d to your computer and use it in GitHub Desktop.
Save etheriqa/89233cbf7657e4f9870d to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
from pymc import Binomial, MCMC, Matplot, Uniform
n_iter = 10000
n_problem = 30
n_problem_pass = 18
score = [26, 28, 25, 22, 25]
p = Uniform('p', 0., 1.)
x = Binomial('x', n=n_problem, p=p, value=score, observed=True)
y = Binomial('y', n=n_problem, p=p)
m = MCMC([p, x, y])
m.sample(n_iter)
Matplot.plot(y)
print('pass rate: {0:f} %'.format(len(list(filter(lambda x: x >= n_problem_pass, m.trace('y')))) / 100.))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment