Created
January 25, 2016 07:27
-
-
Save takoika/f9b166fceb599645e5e9 to your computer and use it in GitHub Desktop.
Python code call dice2.stan with generating data.
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
!/usr/bin/env python | |
import pystan | |
import numpy | |
import random | |
import matplotlib.pyplot as plt | |
m = 6 | |
N = 10000 | |
theta = [1/float(m) for i in range(m)] | |
ds = [random.choice([i+1 for i in range(6)]) for i in range(2*N)] | |
d = [] | |
for i in range(N): | |
d.append(ds[2*i]+ds[2*i+1]) | |
x = [0 for i in range(2,2*m+1)] | |
for dd in d: | |
x[dd-2] += 1 | |
dice_data = {'m': m, 'N': N, 'x': x} | |
fit = pystan.stan(file='dice2.stan', data=dice_data, iter=100000, chains=1) | |
print(fit) | |
fit.plot() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment