Some Lottery Problems
In [1], the following lottery problem is discussed: Randomly choose
Without Replacement | With Replacement | |
---|---|---|
Ordered | ||
Unordered |
Here I am most interested in the unordered-with replacement case. The key idea is that: to choose
Last, for teaching purpose, we may want to see the sample space in the case of given small
n <- 4
r <- 3
my_list <- vector(mode = "list")
s <- 0
for(i in 0:r)
for(j in 0:r)
for(k in 0:r)
for(m in 0:r) {
if(i + j + k + m == r) {
s <- s + 1
my_list[[s]] <- paste0(rep(1:n, times = c(i, j, k, m)), collapse = "")
}
}
sort(do.call(rbind, my_list))
## [1] "111" "112" "113" "114" "122" "123" "124" "133" "134" "144" "222" "223"
## [13] "224" "233" "234" "244" "333" "334" "344" "444"
References
[1] Casella, G. and Berger, R. (2002). Statistical Inference.