fork download
  1. # Two bonus
  2. bonus_A <- c(2500, 2000, 1500,
  3. rep(250, 10), rep(150, 10))
  4. bonus_B <- c(3500, 2000, 600,
  5. rep(250, 10), rep(70, 10))
  6.  
  7. ## Simulate 100000 bets ----
  8. set.seed(20200722)
  9. # Times of simulation
  10. Nsim <- 1e+5
  11. # 100000 outcome
  12. OP_A <- OP_B <- vector(length = Nsim)
  13. # pool
  14. pool <- sprintf("%04.f",0:9999)
  15. # principal
  16. principal <- 1
  17. for(n in 1:Nsim){
  18. # cat(n, "/",Nsim)
  19. bet_num <- sample(pool, 1)
  20. Lotto_result <- sample(pool, 23, replace = T)
  21. OP_A[n] <- sum((Lotto_result==bet_num)*bonus_A) - principal
  22. OP_B[n] <- sum((Lotto_result==bet_num)*bonus_B) - principal
  23. # cat("\014")
  24. }
  25.  
  26. ## Output ----
  27. # counts
  28. table(OP_A)
  29. table(OP_B)
Success #stdin #stdout 2.14s 52824KB
stdin
Standard input is empty
stdout
OP_A
   -1   149   249  1499  1999  2499 
99793    90    91     6    10    10 
OP_B
   -1    69   249   599  1999  3499 
99793    90    91     6    10    10