Advertisement
Guest User

Untitled

a guest
May 8th, 2021
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.04 KB | None | 0 0
  1. great_wins1 <- rep(NA, 1000)
  2. great_wins2 <- rep(NA, 1000)
  3.  
  4. ## run sim 1000 times to look at sample means
  5. for (j in 1:1000){
  6.  
  7.   ## run scenario 1 1000 times and extract sample mean
  8.   ## for great players winning it all
  9.   win_vec <- rep('none', 1000)
  10.  
  11.   for (i in 1:length(win_vec)){
  12.     while (win_vec[i] == 'none'){
  13.       win_vec[i] <- scenario1()
  14.     }
  15.   }
  16.   great_wins1[j] <- length(which(win_vec == 'great'))
  17.  
  18.   ## run scenario 2 1000 times and extract sample mean
  19.   ## for great players winning it all
  20.   win_vec2 <- rep('none', 1000)
  21.  
  22.   for (i in 1:length(win_vec)){
  23.     while (win_vec2[i] == 'none'){
  24.       win_vec2[i] <- scenario2()
  25.     }
  26.   }
  27.   great_wins2[j] <- length(which(win_vec2 == 'great'))
  28. }
  29.  
  30. t.test(x = great_wins1, y = great_wins2, 'less')
  31.  
  32. hist(great_wins1/length(great_wins1), xlab = 'Percentage of Great Player Wins: Scenario 1',
  33.      main = 'Histogram of Win Percentage')
  34.  
  35. hist(great_wins2/length(great_wins2), xlab = 'Percentage of Great Player Wins: Scenario 2',
  36.      main = 'Histogram of Win Percentage')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement