Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import pymc as pm
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5. # Generate fake data
  6. data_scores = np.random.normal(0.5, 0.1, size=50)
  7.  
  8.  
  9. mu = pm.Uniform("mu", lower=0, upper=1)
  10. tau = pm.Uniform("tau", lower=0, upper=500)
  11. scores = pm.Normal("score", mu=mu, tau=tau, observed=True, value=data_scores)
  12. model = pm.Model([scores, mu, tau])
  13. mcmc = pm.MCMC(model)
  14. mcmc.sample(40000, 10000, 1)
  15.  
  16. mu_samples = mcmc.trace('mu')[:]
  17.  
  18. plt.hist(mu_samples, bins=30)
  19. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement