彩券號碼

不重複抽樣

numArr <- sample(1:100, replace=F) numArr

[1] 49 3 4 62 83 98 9 65 7 43 18 24 97 8 80 38 86 [18] 15 54 73 88 67 6 35 42 25 22 51 44 5 45 76 91 94 [35] 64 32 84 61 68 71 30 59 12 70 33 66 20 17 1 29 11 [52] 10 56 16 46 13 36 28 21 93 23 99 82 52 57 60 69 75 [69] 19 48 39 81 50 34 79 53 58 63 14 40 37 26 47 90 72 [86] 78 96 31 27 2 100 77 95 41 89 74 92 87 85 55

擲 10 次骰子

numArr <- sample(1:6, 10, replace=T) numArr

彩劵

numArr <- sample(1:49, 7, replace=F) numArr

46 28 27 5 18 20 21

# 10 位數發生機率 f0 <- 0.1 f1 <- 0.3 f2 <- 0.1 f3 <- 0.2 f4 <- 0.3 firstDigit <- sample(0:4, 7, replace=T, prob=c(f0, f1, f2, f3, f4)) # 個位數發生機率 t0 <- 0.05 t1 <- 0.1 t2 <- 0.1 t3 <- 0.15 t4 <- 0.1 t5 <- 0.1 t6 <- 0.1 t7 <- 0.15 t8 <- 0.05 t9 <- 0.1 lastDigit <- sample(0:9, 7, replace=T, prob=c(t0, t1, t2, t3, t4, t5, t6, t7, t8, t9)) # 數列加總 numArr <- 10 * firstDigit + lastDigit numArr

24 22 12 45 13 27 16