Guest User

Untitled

a guest
Feb 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. with pm.Model() as sleep_model:
  2.  
  3. # Create the alpha and beta parameters
  4. # Assume a normal distribution
  5. alpha = pm.Normal('alpha', mu=0.0, tau=0.05, testval=0.0)
  6. beta = pm.Normal('beta', mu=0.0, tau=0.05, testval=0.0)
  7.  
  8. # The sleep probability is modeled as a logistic function
  9. p = pm.Deterministic('p', 1. / (1. + tt.exp(beta * time + alpha)))
  10.  
  11. # Create the bernoulli parameter which uses observed data to inform the algorithm
  12. observed = pm.Bernoulli('obs', p, observed=sleep_obs)
  13.  
  14. # Using Metropolis Hastings Sampling
  15. step = pm.Metropolis()
  16.  
  17. # Draw the specified number of samples
  18. sleep_trace = pm.sample(N_SAMPLES, step=step);
Add Comment
Please, Sign In to add comment