【发布时间】:2014-10-07 13:10:17
【问题描述】:
我刚刚生成了 10 个从 1 到 39 的随机乐透号码,现在我想检查这些号码是否与我的中奖彩票匹配,例如 w<-c(2,8,19,23,25,32,37),这样如果我有 3 场比赛特别组合,则奖金为 4 50 的 10 美元5 100 美元 6 2000 美元和所有 7 100000 美元。
set.seed(99)
y <- replicate(10,sample(1:39,7,replace=FALSE))
dimnames(y) <- list(rownames(y,do.NULL=FALSE,prefix=""),
colnames(y,do.NULL=FALSE,prefix="Combination"))
m <- t(y)
(m2 <- t(apply(m,1,sort)))
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
Combination1 5 19 23 26 33 36 39
Combination2 7 12 14 18 20 22 37
Combination3 4 7 8 14 25 27 36
Combination4 1 4 13 22 27 28 32
Combination5 1 2 8 12 13 19 37
Combination6 16 18 22 27 30 31 35
Combination7 13 15 18 20 31 34 36
Combination8 5 10 27 28 29 31 35
Combination9 4 10 14 21 23 33 35
Combination10 1 17 20 28 29 32 33
【问题讨论】:
标签: r simulation