Race to 9001

<p>oh white parents</p>

<p>Not even halfway there! Son I am disappoint</p>

<p>I’m sorry.</p>

<p>Only4344postswhyno9001?.gif</p>

<p>Filing taxes. Then, I bit my tongue hard while eating an orange. </p>

<p>Next few days are gonna be irritating. . .</p>

<p>last day of school before break :D</p>

<p>

</p>

<p>You late to the party hanana -.-</p>

<p>dumping this code for simulating lotteries since Megamillions is so big. If someone with experience in R wants to help optimize it, knock yourself out. I’m going to work on making it possible to buy multiple tickets</p>

<p>


lotterysim <- function(jackpot) {
  ## create lottery result
  repeat {
    reg.act <- ceiling(runif(5,0,56))
    test <- T
    for (i in 1:5) {
      test <- min((reg.act[-i]-reg.act*)!=0)
      if (!test) break
    }
    if (test) break
  }
  repeat {
    power.act <- ceiling(runif(1,0,56))
    test <- min((reg.act-power.act)!=0)
    if (test) break
  }</p>

<p>## Create user numbers
  repeat {
    reg.use <- ceiling(runif(5,0,56))
    test <- T
    for (i in 1:5) {
      test <- min((reg.use[-i]-reg.use*)!=0)
      if (!test) break
    }
    if (test) break
  }
  repeat {
    power.use <- ceiling(runif(1,0,56))
    test <- min((reg.use-power.use)!=0)
    if (test) break
  }</p>

<p>## Check number of matches
  reg.count <- 0
  pow.count <- (power.act==power.use)
  for (i in 1:5) {
    test <- max(reg.act==reg.use*)
    if (test) reg.count <- reg.count+1
  }</p>

<p>## Calculate Winnings
  if (pow.count == 1) {
    if (reg.count == 5) return(jackpot)
    if (reg.count == 4) return(10000)
    if (reg.count == 3) return(150)
    if (reg.count == 2) return(10)
    if (reg.count == 1) return(3)
    if (reg.count == 0) return(2)
  }
  else {
    if (reg.count == 5) return(250000)
    if (reg.count == 4) return(150)
    if (reg.count == 3) return(7)
    if (reg.count < 3) return(0)
  }
}</p>

<p>result <- replicate(10000,lotterysim(540000000))

</p>

<p>incidentally i just started going through some R tutorials. the most i can do so far is interpret what someone means when they use a capital r like you just did though.</p>

<p>what does it mean to simulate a lottery like that, what does it do, if you don’t mind explaining…?</p>

<p>

</p>

<p>Alternatively,</p>

<p>

</p>

<p>though it makes since because New Zealand is like upsidedown America, so it’s the opposite</p>

<p>The ## indicates comments, and I’ve finished the code that allows multiple tickets, so you can read it with the comments</p>

<p>


lotterysim <- function(jackpot,numtick) {
  ## create lottery result
  repeat {
    ## draws 5 random numbers from a discrete uniform distribution and puts them in a vector
    reg.act <- ceiling(runif(5,0,56)) 
    test <- T
    ## want to make sure there are no repeats in the vector
    for (i in 1:4) {
      ## subtract the ith item in the vector from the rest of the elements
      ## if one of them is zero, set test to be FALSE
      test <- min((reg.act[-i]-reg.act*)!=0)
      ## if test becomes FALSE, stop the for loop 
      if (!test) break
    }
    ## if test isn't FALSE, the numbers drawn are valid, otherwise draw new numbers
    if (test) break
  }
  repeat {
    ## draw a single random number for the powerball
    ## make sure it's different from the regular numbers
    power.act <- ceiling(runif(1,0,56))
    test <- min((reg.act-power.act)!=0)
    if (test) break
  }</p>

<p>## Create user numbers
  ## initialize a matrix to hold the user's number choices
  ## each row holds a set of choices
  reg.use <- matrix(0,ncol=6,nrow=numtick)
  ## for each ticket you buy, draw 6 numbers
  ## use the same method as above to make sure there aren't any overlaps
  for (j in 1:numtick) {
    repeat {
      reg.use[j,] <- ceiling(runif(6,0,56))
      test <- T
      for (i in 1:5) {
        test <- min((reg.use[j,-i]-reg.use[j,i])!=0)
        if (!test) break
      }
      if (test) break
    }
  }</p>

<p>## Check number of matches
  ## initializes vectors of length the number of tickets bought
  reg.count <- numeric(numtick)
  pow.count <- numeric(numtick)
  for (j in 1:numtick) {
    ## initialize as 0
    reg.count[j] <- 0
    ## check whether the powerball matches one of the numbers
    pow.count[j] <- (power.act==reg.use[j,])
    ## for each of the user's regular balls check if there's a match
    ## if so, increment the count for that ticket
    for (i in 1:6) {
      test <- max(reg.act==reg.use[j,i])
      if (test) reg.count[j] <- reg.count[j]+1
    }
  }</p>

<p>## Calculate Winnings
  winnings = 0
  for (i in 1:numtick) {
    if (pow.count* == 1) {
      if (reg.count* == 5) winnings <- winnings + jackpot
      if (reg.count* == 4) winnings <- winnings + 10000
      if (reg.count* == 3) winnings <- winnings + 150
      if (reg.count* == 2) winnings <- winnings + 10
      if (reg.count* == 1) winnings <- winnings + 3
      if (reg.count* == 0) winnings <- winnings + 2
    }
    else {
      if (reg.count* == 5) winnings <- winnings + 250000
      if (reg.count* == 4) winnings <- winnings + 150
      if (reg.count* == 3) winnings <- winnings + 7
      if (reg.count* < 3) winnings <- winnings + 0
    }
  }
  return(winnings-numtick)
}</p>

<h2>sets the jackpot to be 540 million</h2>

<p>jackpot <- 540000000</p>

<h2>system.time measures how long it takes for a function to run</h2>

<h2>replicates(10000, lotterysim(jackpot,10)) calls the function</h2>

<h2>lotterysim(...) 10000 times and creates a vector with each result</h2>

<p>system.time(result <- replicate(10000,lotterysim(jackpot,10)))

</p>

<p>If anyone is even remotely interested in sports and/or different cultures from around the world, give Africa United a try. It’s a very well written book about how soccer can bring countries together. Even though I don’t like soccer particularly, I actually like this book.</p>

<p>[Amazon.com:</a> Africa United: Soccer, Passion, Politics, and the First World Cup in Africa (9781847677785): Steve Bloomfield: Books](<a href=“http://www.amazon.com/gp/product/B004KAB82U/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=486539851&pf_rd_s=lpo-top-stripe-1&pf_rd_t=201&pf_rd_i=1847676588&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=0P1QRBASH8TCNB3AH0T2]Amazon.com:”>http://www.amazon.com/gp/product/B004KAB82U/ref=pd_lpo_k2_dp_sr_1?pf_rd_p=486539851&pf_rd_s=lpo-top-stripe-1&pf_rd_t=201&pf_rd_i=1847676588&pf_rd_m=ATVPDKIKX0DER&pf_rd_r=0P1QRBASH8TCNB3AH0T2)</p>

<p>[url=&lt;a href=“http://talk.collegeconfidential.com/parents-forum/862196-get-your-kid-major-mathematics-now.html]This[/url”&gt;http://talk.collegeconfidential.com/parents-forum/862196-get-your-kid-major-mathematics-now.html]This[/url</a>] thread went downhill fast</p>

<p>9001 is a big number. DO you think we can make it before the aliens fly in and take over our internet?</p>

<p>Octave is where it’s at.</p>

<p>What’s the difference between Octave and MATLAB</p>

<p>It’s amazing how so many people are afraid of the government … unless the government worker actually has a gun … in that case their work should never be questioned.</p>

<p>That’s clever. I like it</p>

<p>Let’s play hangman. </p>

<p>First person to guess word correctly wins a prize. Here is the word: </p>

<hr>

<p>A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</p>

<p>

</p>

<p>how did it go downhill fast?</p>