Kelly criterion and lottery tickets

Suppose you have a bet which loses money most of the time, but wins a massive amount now and then, how much money should you put on it? Let's say the 1 time you win, you win $a for each dollar you bet, and the N times you lose, you lose $b for each dollar you bet. By the Kelly criterion, the geometric average rate of gain if you bet $latex x$ of your wealth would be $latex R = (1+xa)(1-xb)^n$ Setting $latex \partial_x R = 0$, you get $latex x = \frac{a - nb}{(n+1)ab} = \frac{\left<\mathrm{arithmetic\ gain}\right>}{ab}$ Suppose you are asked to flip a coin, and heads you win $3, and tails you lose $1---then $latex n=1, a=2,b=1$, and therefore $latex x = \frac{1}{2 \cdot 2} = \frac{1}{4}$, i.e., you should bet 25% of your wealth. If you have a lottery ticket that has a 1 out of 5,000 chance of winning $10,000 that costs $1, and you are only allowed to buy one number, then $latex n=4999,a=9999, b=1$, and $latex x = \frac{5000}{49999 \cdot 9999} \approx 10000^{-1}$ and you should only bet 0.01% of your wealth at a time. Conversely, if you were selling a lottery ticket that had 1 out of 10,000 chance of winning $5,000 that cost $1, $latex n = 9999, a = -4999, b = -1$, and $latex x = \frac{5000}{9999\cdot4999} \approx 10000^{-1}$ and you should be trying to have about 0.01% of your wealth at stake. Related: Do not play the lottery unless you are a millionaire