Created
November 27, 2012 04:17
-
-
Save jknowles/4152338 to your computer and use it in GitHub Desktop.
Making lottery numbers that are less likely to results in splitting the winnings.
This file contains 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 characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment