Advertisement
Guest User

Untitled

a guest
Dec 14th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. allwomen <- rep(0,1000000)     # one million un-raped women
  2. rapes <- 250000                # 250,000 rapes
  3.  
  4. for (i in 1:rapes){
  5.    victim <- round(runif (1,0,length(allwomen)))         # Pick a victim at random
  6.    allwomen[victim] <- allwomen[victim] + 1              # record the rape
  7. }
  8.  
  9. hist(allwomen)                         # plot a graph of the rape distribution
  10. length(allwomen[allwomen==0])          # How many women are un-raped
  11. length(allwomen[allwomen>=1])          # How many are raped
  12. length(allwomen[allwomen>=1])/1000000  # percentage of rape victims
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement