Guest User

Untitled

a guest
Mar 11th, 2019
95
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set.seed(123)
  2. n_m = n_f = p1 = p2 = list()
  3. n_m$total = sample(5:20)
  4. n_m$success = sapply(n_m$total, function(x) rbinom(1, x, .5))
  5.  
  6. n_f$total = sample(5:20)
  7. n_f$success = sapply(n_f$total, function(x) rbinom(1, x, .5))
  8.  
  9.  
  10. p1$m = n_m$success/n_m$total
  11. p1$f = n_f$success/n_f$total
  12.  
  13. p2$m = sum(n_m$success)/sum(n_m$total)
  14. p2$f = sum(n_f$success)/sum(n_f$total)
  15.  
  16.  
  17. > n_m
  18. $total
  19. [1] 9 16 10 19 17 5 18 13 20 8 14 7 12 6 15 11
  20.  
  21. $success
  22. [1] 3 5 4 13 11 3 10 11 11 5 7 4 5 2 11 8
  23.  
  24. > n_f
  25. $total
  26. [1] 16 20 5 11 14 7 8 15 6 13 17 12 18 19 10 9
  27.  
  28. $success
  29. [1] 7 12 1 5 9 2 4 6 2 8 11 5 10 7 5 4
  30.  
  31.  
  32. > mean(p1$m/p1$f)
  33. [1] 1.293038
  34. > p2$m/p2$f
  35. [1] 1.153061
  36. >
RAW Paste Data