-
-
Save vicmansep/119de23cfa71844763c0fa0973773b77 to your computer and use it in GitHub Desktop.
Revisions
-
jknowles created this gist
Nov 27, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ # Generate lotto numbers # Avoid a split pot # Author: Jared Knowles # Date: 11/26/2012 # All numbers are equally likely to be selected to win in PowerBall, # but what fun is winning if we have to share the pot? # Therefore, we will only select numbers that minimize our # likelihood of sharing the pot. gen_lotto<-function(){ white<-seq(1:59) red<-31:39 probs<-white # Decrease probabilities for commonly chosen numbers probs[probs<=31]<-1/(2*59) probs[probs>=32]<-1/14 # We need 5 white w<-sample(white,5,prob=probs) # We need 1 PowerBall r<-sample(red,1) # Print results cat(" White Balls:",w[order(w)],"\n","Powerball:",r) # Make a good warning cat("\n Remember, your odds of winning: \n","1 in 195,249,054") } gen_lotto()