Advertisement
justsing

MPQ 4 star pulling

Jun 6th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.64 KB | None | 0 0
  1. ### MPQ 4* pulling
  2. ### justsing
  3. ### June 6, 2018
  4.  
  5. ## Setup
  6.  
  7. n4 = 65
  8. nlatest = 12
  9. p4_lt = 0.85
  10. p_lt_current = p4_lt/(2*nlatest*3)
  11. p_lt_new = p4_lt/(n4*3)
  12.  
  13. coptions = c(1, 2, 3, 4, 5)
  14.  
  15. ## Simulation Functions
  16.  
  17. pull_noBH <- function(coverlist, pcover, p4){
  18.   totalpulls = 0
  19.   covers = rep(0, 5)
  20.   plist = c(rep(pcover, 3), (p4-3*pcover), (1-p4))
  21.   while (sum(covers[1:3]) < 13){
  22.     totalpulls = totalpulls + 1
  23.     pull = sample(coverlist, 1, prob=plist)
  24.     covers[pull] = min((covers[pull]+1), 5)
  25.   }
  26.   totalpulls
  27. }
  28.  
  29. pull_BH <- function(coverlist, pcover, p4){
  30.   totalpulls = 0
  31.   covers = rep(0, 5)
  32.   plist = c(rep(pcover, 3), (p4-3*pcover), (1-p4))
  33.   while (sum(covers[1:3]) < 13){
  34.     totalpulls = totalpulls + 1
  35.     pull = sample(coverlist, 1, prob=plist)
  36.     covers[pull] = min((covers[pull]+1), 5)
  37.     if (pull <= 4){
  38.       bonus = sample(coverlist[1:4], 1, prob=c(0.05/3, 0.05/3, 0.05/3, 0.95))
  39.       covers[bonus] = min((covers[bonus]+1), 5)
  40.     }
  41.   }
  42.   totalpulls
  43. }
  44.  
  45. ### Run simulations
  46.  
  47. set.seed(17)
  48. nsims = 100000
  49.  
  50. lt_current_noBH = replicate(nsims, pull_noBH(coverlist=coptions, pcover=p_lt_current, p4=p4_lt))
  51. lt_current_BH = replicate(nsims, pull_BH(coverlist=coptions, pcover=p_lt_current, p4=p4_lt))
  52. lt_new_noBH = replicate(nsims, pull_noBH(coverlist=coptions, pcover=p_lt_new, p4=p4_lt))
  53. lt_new_BH = replicate(nsims, pull_BH(coverlist=coptions, pcover=p_lt_new, p4=p4_lt))
  54.  
  55. lt_results = as.data.frame(cbind(lt_current_noBH, lt_current_BH, lt_new_noBH, lt_new_BH))
  56. summary(lt_results)
  57.  
  58. sapply(lt_results, mean)
  59. sapply(lt_results, sd)
  60. sapply(lt_results, quantile, probs = c(0.5, 0.25, 0.75, 0.05, 0.95))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement