Advertisement
Guest User

dice

a guest
Dec 5th, 2014
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. n <- 1e7
  2.  
  3. # Max of 2d20
  4.  
  5. r1 <- sample(1:20,n,T)
  6. r2 <- sample(1:20,n,T)
  7. max.r1r2 <- apply(as.matrix(cbind(r1,r2)),1,max)
  8.  
  9. # Reroll 1d20 if < N
  10.  
  11. N <- 10
  12.  
  13. r3 <- sample(1:20,n,T)
  14. r3[r3 < N] <- sample(1:20,length(which(r3 < N)),T)
  15.  
  16. # compare using hist() or similar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement