Created
December 26, 2015 23:36
-
-
Save johnckane/21ba25656e20033f2035 to your computer and use it in GitHub Desktop.
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
perm_df <- data.frame(run = integer(), | |
p1 = integer(), | |
p2 = integer(), | |
p3 = integer(), | |
p4 = integer(), | |
p5 = integer(), | |
p6 = integer(), | |
p7 = integer(), | |
p8 = integer(), | |
p9 = integer(), | |
p10 = integer(), | |
p11 = integer(), | |
p12 = integer(), | |
score = integer()) | |
set.seed(101) | |
for(i in 1:10000){ | |
a1 <- sample(c(7:12), 6, replace = FALSE) | |
a2 <- sample(c(3:6), 2, replace = FALSE) | |
a3 <- sample(c(1:6)[-a2], 4, replace = FALSE) | |
perm_df[i,1] <- i | |
perm_df[i,c(8:13)] <- a1 | |
perm_df[i,c(6:7)] <- a2 | |
perm_df[i,c(2:5)] <- a3 | |
perm_df$score <- 0 | |
} | |
for(j in 1:10000){ | |
if(perm_df[j,2] == 1){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,3] == 2){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,4] == 3){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,5] == 4){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,6] == 5){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,7] == 6){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,8] == 7){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,9] == 8){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,10] == 9){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,11] == 10){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,12] == 11){perm_df$score[j] <- perm_df$score[j] + 1} | |
if(perm_df[j,13] == 12){perm_df$score[j] <- perm_df$score[j] + 1} | |
} | |
table(perm_df$score)/10000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment