Skip to content

Instantly share code, notes, and snippets.

@trinker
Created June 9, 2022 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trinker/d18106214ace650da2312d2b652fbcee to your computer and use it in GitHub Desktop.
Save trinker/d18106214ace650da2312d2b652fbcee to your computer and use it in GitHub Desktop.
prob <- unlist(lapply(1:1000000, function(i){
candles <- sort(runif(2, 0, 1))
cut <- runif(1, 0, 1)
(cut > candles[1]) & (cut < candles[2])
}))
mean(prob)
## Assuming 4 poker players
dat <- data.frame(
suit = rep(c('H', 'C', 'S', 'D'), each = 14),
value = rep(c(1:10, 'J', 'Q', 'K', 'A'), 4),
representation = unlist(lapply(1:4, function(i) c(rep(NA, 9), rep(i, 5)))),
id = 1:56
)
nplayers = 4
m = sample(dat$representation);m
matrix(m, ncol = 4, byrow=TRUE)
matrix(sample(dat$representation), ncol = 4, byrow=TRUE)
(length(na.omit(x)) == 5) & (length(unique(x)) == 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment