小编Nik*_*ola的帖子

乐透功能与 R

我刚刚生成了从 1 到 39 的 10 个随机乐透号码,现在我想检查这些号码是否与我的中奖彩票匹配,例如 w<-c(2,8,19,23,25,32,37),如果我有 3 个特定组合的匹配,则奖金为 10 美元 4 50 美元 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 …
Run Code Online (Sandbox Code Playgroud)

simulation r

3
推荐指数
1
解决办法
1939
查看次数

标签 统计

r ×1

simulation ×1