Download or view lottery.frink in plain text format
// Functions for predicting lottery or Keno probabilities.
// balls is the number of total balls to draw from
// drawn is the number of balls actually drawn from the above pool
// chosen is the number of balls chosen by the player
// matches is the number of balls chosen by the player that match drawn balls
lottery[balls, drawn, chosen, matches] :=
{
binomial[chosen, matches] * binomial[balls-chosen, drawn-matches] / binomial[balls,drawn]
}
/* Powerball Examples:
NOTE: The rules below may change. The rules were changed for the
2015-10-07 drawing and later, and may change. For official payoffs see:
http://www.powerball.com/powerball/pb_prizes.asp
Powerball draws five white balls out of a drum with 69 balls and one red
powerball out of a drum with 26 red balls. To win the grand prize, you
must match the 5 hite balls (in any order) and the red powerball.
To calculate the odds of winning the grand prize, you would do:
lottery[69, 5, 5, 5] * 1/26
To calculate the odds of matching 5 white balls but NOT the powerball (this
is a $1 million prize):
lottery[69, 5, 5, 5] * 25/26
To calculate the odds of matching exactly 4 white balls AND the powerball:
lottery[69, 5, 5, 4] * 1/26
To calculate the odds of matching exactly 4 white balls but NOT the
powerball:
lottery[69, 5, 5, 4] * 25/26
...
To calculate the odds of matching 1 white ball and matching the powerball:
lottery[69, 5, 5, 1] * 1/26
To calculate the odds of matching no white balls but matching the powerball:
lottery[69, 5, 5, 0] * 1/26
To calculate the odds of matching nothing at all:
lottery[69, 5, 5, 0] * 25/26
*/
Download or view lottery.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20145 days, 7 hours, 10 minutes ago.