Last active
January 25, 2016 07:22
-
-
Save takoika/58ddb0e8ff0ded27d2df to your computer and use it in GitHub Desktop.
Stan code for inferring probabilities of m-face dice from the number of occurrences of an outcome which is sum of two m-dice's outcomes.
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
data | |
{ | |
int <lower=0> m; // The number of dice faces | |
int <lower=0, upper=N> x[2*m-1]; // The numbers of events. x[i] indeicates the number of occurences that a sum of two dices is i+1 in [2,...,2*m]. | |
} | |
parameters | |
{ | |
simplex[m] theta1; // Probability for each face. | |
simplex[m] theta2; // Probability for each face. | |
} | |
model { | |
vector [2*m-1] phi; | |
for (s in 2:2*m) { | |
phi[s-1] <- 0.; | |
for (a in max(1,s-6):min(6,s-1)) { | |
phi[s-1] <- phi[s-1]+theta1[a]*theta2[s-a]; // Summing up probabilities that a sum of two dice's outcomes equals s. | |
} | |
x ~ multinomial(phi); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment