simple underscore.js projects, walk through, & tutorial
Lottery DataBase Analysis - 03 (_.reduce)
California Lucky for Life (832)
Prizes
Odds 1 in
Total # of Winners
$3,250,000.00
2400000
17
$5,000.00
1200000
34
$1,000.00
400000
102
$500.00
12000
3400
$100.00
645
63240
$40.00
350
116620
$20.00
53
765000
$15.00
40
1020000
$10.00
20
2040000
$5.00
11
3570000
Ticket ($5)
10
4080000
There are more data points available on the lottery website, so I grabbed the Total # of Winners.
var numberEachPrize = [17,34, 102, 3400, 63240, 116620, 765000, 1020000, 2040000, 3570000, 4080000];
document.getElementById('outputOne').innerHTML = _.map(numberEachPrize, function(n){return ' ' + n;});
Yields:
Nada Yet
Multiplying the Individual Prize Odds by the Number of Each Prize should yield a Total Number of Tickets.
outputTwo = 2400000 * 17;
Yields:
Nada Yet
Which can be eyeballed against the free ticket odds (10 x 4080000)
So, that looks good.
And then, to find the overall odds, adding up the Total Number of All Prizes Available would be a good next step. So,
var outputThree = _.reduce(numberEachPrize, function(memo, num){return memo + num;}, 0);
With Total Number of All Prizes equaling =
Nada Yet
Overall odds (if I know any probability at all) should be given by: #Wins / #Tries
var outputFour = outputTwo / outputThree;
Yields an overall win rate of 1 in
Nada Yet
which compares favorably to odds listed on ticket (1:3.50)
To double check, back out the winning tickets.
var outputFive = outputTwo / (outputThree - 4080000);
And we have odds to win any prize:
Nada Yet
which once again is spot on to the value on the ticket (1:5.38)
Even more so, since the rounding occurs as one might like (in either direction, per standard rules).
So, throw out the previous web page (don't know what I was thinking) and we'll use the logic on this page from here on out.
Please Note: I am an idiot. No seriously. The odds of my gambling
odds calculations being correct are likely on par with my odds of ever
winning. You have been warned.