Thursday, December 26, 2013

Is the lottery a smart bet?

It is said that the lottery is a tax on people who are bad at math. What is intended by this is that the odds of winning the lottery as so miniscule that a rational cost-benefit analysis would recommend against participation. But is this always true? Since the jackpot “rolls over” and accumulates for successive drawings, is there some threshold at which the value of a lottery ticket exceeds the price?

Let’s consider the Megamillions lottery played Tuesday night. As has been well documented elsewhere, the probability of buying a winning number for a particular draw can be calculated thus:

Lottery Math

Number of balls in main cage: 75
Number of balls drawn from main cage: 5
Number of balls in Megaball cage: 15

Number of possible combinations of the six balls: clip_image002[6]

Probability of drawing correct number:


It follows that if the net present value of the lottery jackpot exceeds $N, then a $1 lottery ticket becomes a good investment. Correct?

First, consider that the net present value of the lottery jackpot is not the advertised jackpot. The one-time payout for last week’s $636M jackpot is only $340M, whose value is then diminished by federal, state, and local income taxes at (roughly) 45%. So the winner’s after-tax take is only $187M.

Yet not even this is the net present value. We must also consider the probability that, as happened last night, the jackpot is shared between multiple winners. What is that probability?

Number of Tickets sold: T

The probability that at least one winning lottery ticket (i.e., w ≥ 1) would be sold: p(T)

Each successive ticket t purchased adds to the total probability of a winning ticket p(t) the probability P multiplied by the probability that none of the earlier tickets were successful, which is 1 – p(t-1). Thus:





Last week’s drawing had 336M participants. Thus:


for P as calculated above.

We included in that that 73% probability the chance that multiple winning tickets were selected. But since multiple tickets means splitting the prize, then the expected value of the prize is the jackpot divided by the expected (e.g., the average over multiple trials) number of winners. Can this be calculated?

In general, the formula for the expected value of random variable W is

clip_image016 ,

i.e., the sum, over all possible values of w, of the product of w and the probability of w. In this case, W is the random variable describing the number of winners, w is a specific number of winners, and p(w) is the probability of that w winners.

Given P as calculated above, let’s shift variables and designate p(T,w) as the probability of exactly w winners given T tickets sold.

The probability of one winner when one ticket is sold: p(1,1) = P

The probability of one winner when two tickets are sold:

The probability of one winner when three tickets are sold:


In our application, the number of tickets T is presumably fixed and known. We are also interested in knowing how the probability changes with w, the number of winners. Each ticket is an independent event, so:

The probability of two winners when two tickets are sold: p(2,2) = PP = P2

The probability of two winners when three tickets are sold:


“Wait a second!” the astute among you are saying about now, “that’s starting to look like the binomial theorem!” Indeed it does. In fact, we can generalize that for exactly k winners among T tickets sold, the probability is:


i.e., the product of the probabilities of all winners and losers and the number of ways we can combine them.

In our calculation of the expected value, it would be nice if we could apply the binomial theorem,


but we can’t, because we must weight the terms by as written, because we must weight the terms by w:


Unfortunately, I’m not good enough at math enough to figure out a closed-form solution to the summation above without knowing the answer in advance. And the usual way of evaluating clip_image002[10], with factorials as show above, won’t work when T is hundreds of millions of tickets sold; no computer generates factorials that large. But the Wikipedia article suggests using iteration and logarithms to calculate clip_image002[12] for large T, which I have done in Matlab here:

% Parameters
n = 75; % Number of balls in main bin
v = 5;  % Number of balls drawn from main bin
m = 15; % Number of balls in MegaBin
N = m*nchoosek(n,v); % Number of possible lottery combinations
P = 1/N; % Probability of receiving the winning number
% Calculate the binomial coefficients with logarithms
T = N;   % Arbitrarily set the number of number of tickets sold to 239E6; we vary this number over multiple runs
i = 1:T; % A vector containing all integers between 1 and T
logi = log(i); % Calculate the logarithm of all integers between 1
% and T
logu = 0;
logl = 0;
for k = i,
logu = logu + logi(T-k+1);
logl = logl + logi(k);
logBC(k) = logu – logl; % the natural log of the binomial coefficient, i.e. log[(T k)]
% Calculate the expected value
logP = log(P);
logQ = log(1-P);
% natural log of the product of k wins and the probability of k wins
logwpw = logi + logBC + i*logP + (T-i)*logQ;
EW = sum(exp(logwpw)); % Calculate the antilog and sum


Fortunately, on a Xeon X5672 at 3.2GHz, this algorithm can be executed in a few minutes; note, however, that I optimized it for speed by minimizing the contents of the for loop.  The tradeoff is that I have several N-length floating-point vectors that managed to take up 18GB of memory.  Proceed at your own risk!

I ran the program for several values of T, and convinced myself that E[W] = T/N = PT. Now that I know the answer, I’d like a second crack at a closed form solution:



I will now resort to a bit of hand-waving:  given values of T in the hundreds of millions, the value for E[W] is not measurably diminished by conditioned on a given number of winners.  This is analogous to the probability of rolling double-sixes given that you already rolled one six.  (Answer:  1/6, not 1/36.)  So given that you won the jackpot, the number of additional expected winners is still PT.

Applying this to the problem at hand, it follows that the after-tax value of last night’s jackpot must be divided through by 1 (i.e., you) + 336/259 (the other winners), reducing the value of your jackpot share to $81M.

Now, it is theoretically possible that, given a high enough jackpot, that $81M could increase to the $259M necessary to make the expected value of the lottery ticket greater than the dollar you’re paying for it.  But remember that the number of tickets T for any given drawing will probably go up with the increasing jackpot, diminishing its value to an individual player.  And even if it didn’t, it wouldn’t follow that buying multiple tickets would be a good idea.  I will leave working the math out to the reader, but you would be assured of buying duplicate tickets, and thereby playing against yourself, after a few tens of thousands of tickets purchased, and the model would need to be extended to account for this.

(NOTE:  The foregoing was for entertainment purposes only.  Those wishing to invest their life savings in lottery tickets should consult a qualified dissipation professional.)


Anonymous said...

Since the chance of winning is so near zero that you really have a better chance of being struck by lightning ... twice, you really should not be using the word "investment". It is a gamble that you cannot possibly win by planning to or by being "good at it". Even understanding the maths does nothing to improve your chances.

Anonymous said...

I remember once having to do that calculation in college. So I can follow along, but don't expect me to check your work.

Anonymous said...

Oh, also, you would have to add in the expected value of winning each smaller payout. Those I believe would be additive.

heresolong said...

If you were a proper mathematician you would have included the words

"it is clear that" or "it clearly follows then" right before the most confusing and unclear portion of your explanation.

My only quibble with people who sneer at lottery players (not saying you are, just that I've seen it frequently in the past) is that I am perfectly comfortable dropping five or six bucks a year into the remote chance of winning multiple millions of dollars and being set for life. Since I am spending roughly the cost of two nice cups of coffee and less than one pack of cigarettes (which I don't smoke anyway) I don't think that is going to put much of a dent in my retirement. I suspect that most players don't seriously suspect that they will ever win, but the entertainment value of possibly winning is worth something to that person, a value that is never taken into account when doing such calculations.

sykes.1 said...

My father played the numbers when we lived in Boston. That was a mob racket. The mob paid out 60% of the actual theoretical payout, and there were no taxes. So Whitey Bulgers gang was more honest than the government.

Dr. Φ said...

PH: Good point about the lesser payouts; although they are smaller, their probabilities are relatively higher, so I predict their effect will be measurable.

Heresolong: Which is more or less my attitude towards playing the lottery personally. Once the jackpot is high enough to attract enough players to make it likely that someone will in, it seems worth the couple of dollars to put my name in, irrespective the cost/benefit ratios.

Sykes: Notwithstanding what I just wrote, I'm actually opposed to the existence of state lotteries on policy grounds. It puts the state in the business of corrupting public morals, much in the way the Bulgers did.

Dr. Φ said...

I notice, now that the piece is published, that, in addition to my usual quotas of badly edited sentences, the right edges of my equation jpegs have been cut off. I'll try to fix them, but since I'm lazy and probably won't do it for a while, note that you can right-click the images and open them whole in separate tabs.