Statistical Analysis of the number of coin tosses until you have at least ONE dollar if at each toss the probability of losing a dollar is p and of winning, 2 dollars is , 1 - p By Shalosh B. Ekhad Suppose that at each round, you lose a dollar with probability p and win, 2, dollars with probability 1-p and you quit as soon as you reach at least 1 dollar. If p is less than , 2/3 then, of course, sooner or later you will reach your goal. How long should \ it take? Let g(t), be the formal power series, in t, satisfying the algebraic equatio\ n 2 3 3 g(t) - 1 - p (1 - p) t g(t) = 0 and in Maple format g(t)-1-p^2*(1-p)*t^3*g(t)^3 = 0 The probability generating function for the number of rounds until having a \ positive capital is (1 - p) t g (g p t + 1) and in Maple format (1-p)*t*g*(g*p*t+1) By implicit differentiation, we can compute any desired derivative, and henc\ e the expectation, variance, and higher moments. The expected duration, provided, p is smaller than , 2/3, is 2 1/2 -3 p - (-3 p + 2 p + 1) + 1 ------------------------------- 2 6 p - 4 p and in Maple format (-3*p-(-3*p^2+2*p+1)^(1/2)+1)/(6*p^2-4*p) The variance is 2 1/2 - 54 (-1 + p + (-3 p + 2 p + 1) ) (p + 1/3) 2 1/2 2 / 2 ((- p/3 + 2/9) (-3 p + 2 p + 1) + p + p/9 - 2/9) / (p / 2 1/2 3 (3 p - 3 (-3 p + 2 p + 1) + 1) ) and in Maple format -54*(-1+p+(-3*p^2+2*p+1)^(1/2))*(p+1/3)*((-1/3*p+2/9)*(-3*p^2+2*p+1)^(1/2)+p^2+ 1/9*p-2/9)/p^2/(3*p-3*(-3*p^2+2*p+1)^(1/2)+1)^3 The scaled , 3, -th moment about the mean is / 2 1/2 | - 1944 (-1 + p + (-3 p + 2 p + 1) ) (p + 1/3) | \ 4 / 4 3 20 2 \ 2 1/2 5 4 p |1/3 p + 1/3 p - -- p + 4/81 p + 8/81| (-3 p + 2 p + 1) + p - ---- \ 27 / 3 3 2 \ p 8 p 4 p | / / 3 2 1/2 5 / + ---- + ---- - --- - 8/81| / |p (3 p - 3 (-3 p + 2 p + 1) + 1) |- 3 9 27 / / \ \ 2 1/2 54 (-1 + p + (-3 p + 2 p + 1) ) (p + 1/3) 2 1/2 2 / 2 ((- p/3 + 2/9) (-3 p + 2 p + 1) + p + p/9 - 2/9) / (p / 2 1/2 3 \3/2\ (3 p - 3 (-3 p + 2 p + 1) + 1) )| | / / and in Maple format -1944*(-1+p+(-3*p^2+2*p+1)^(1/2))*(p+1/3)*((1/3*p^4+1/3*p^3-20/27*p^2+4/81*p+8/ 81)*(-3*p^2+2*p+1)^(1/2)+p^5-4/3*p^4+1/3*p^3+8/9*p^2-4/27*p-8/81)/p^3/(3*p-3*(-\ 3*p^2+2*p+1)^(1/2)+1)^5/(-54*(-1+p+(-3*p^2+2*p+1)^(1/2))*(p+1/3)*((-1/3*p+2/9)* (-3*p^2+2*p+1)^(1/2)+p^2+1/9*p-2/9)/p^2/(3*p-3*(-3*p^2+2*p+1)^(1/2)+1)^3)^(3/2) The scaled , 4, -th moment about the mean is / |/ 7 31 5 64 4 89 3 125 2 10 \ 2 1/2 - 16 ||p - -- p + -- p - --- p - --- p + -- p + 4/81| (-3 p + 2 p + 1) \\ 18 27 162 243 81 / 7 6 5 4 3 2 \ 10 p 103 p 17 p 469 p 589 p 119 p 14 p | / - ----- + ------ - ----- - ------ + ------ + ------ - ---- - 4/81| / ( 3 18 54 162 486 243 81 / / 2 1/2 (-1 + p + (-3 p + 2 p + 1) ) (p + 1/3) 2 1/2 (3 p - 3 (-3 p + 2 p + 1) + 1) 2 1/2 2 2 ((- p/3 + 2/9) (-3 p + 2 p + 1) + p + p/9 - 2/9) ) and in Maple format -16*((p^7-31/18*p^5+64/27*p^4-89/162*p^3-125/243*p^2+10/81*p+4/81)*(-3*p^2+2*p+ 1)^(1/2)-10/3*p^7+103/18*p^6-17/54*p^5-469/162*p^4+589/486*p^3+119/243*p^2-14/ 81*p-4/81)/(-1+p+(-3*p^2+2*p+1)^(1/2))/(p+1/3)/(3*p-3*(-3*p^2+2*p+1)^(1/2)+1)/( (-1/3*p+2/9)*(-3*p^2+2*p+1)^(1/2)+p^2+1/9*p-2/9)^2 The scaled , 5, -th moment about the mean is / |/ 10 9 59 8 361 7 1460 6 287 5 2519424 (p + 1/3) ||-1/3 p + 14/9 p - -- p - --- p + ---- p - --- p \\ 27 81 243 243 256 4 2344 3 592 2 32 64 \ 2 1/2 11 - --- p + ---- p + ---- p - --- p - ----| (-3 p + 2 p + 1) + p 243 6561 6561 729 6561/ 10 9 8 7 6 5 4 3 11 p 113 p 1084 p 409 p 5237 p 649 p 2024 p 376 p + ------ - ------ + ------- - ------ - ------- + ------ + ------- - ------ 3 9 81 243 729 243 2187 729 2 \ 16 p 352 p 64 | 2 1/2 / / 5 - ----- + ----- + ----| (-1 + p + (-3 p + 2 p + 1) ) / |p 243 6561 6561/ / \ 2 1/2 9 / 2 1/2 (3 p - 3 (-3 p + 2 p + 1) + 1) |- 54 (-1 + p + (-3 p + 2 p + 1) ) \ 2 1/2 2 / 2 (p + 1/3) ((- p/3 + 2/9) (-3 p + 2 p + 1) + p + p/9 - 2/9) / (p / 2 1/2 3 \5/2\ (3 p - 3 (-3 p + 2 p + 1) + 1) )| | / / and in Maple format 2519424*(p+1/3)*((-1/3*p^10+14/9*p^9-59/27*p^8-361/81*p^7+1460/243*p^6-287/243* p^5-256/243*p^4+2344/6561*p^3+592/6561*p^2-32/729*p-64/6561)*(-3*p^2+2*p+1)^(1/ 2)+p^11+11/3*p^10-113/9*p^9+1084/81*p^8-409/243*p^7-5237/729*p^6+649/243*p^5+ 2024/2187*p^4-376/729*p^3-16/243*p^2+352/6561*p+64/6561)*(-1+p+(-3*p^2+2*p+1)^( 1/2))/p^5/(3*p-3*(-3*p^2+2*p+1)^(1/2)+1)^9/(-54*(-1+p+(-3*p^2+2*p+1)^(1/2))*(p+ 1/3)*((-1/3*p+2/9)*(-3*p^2+2*p+1)^(1/2)+p^2+1/9*p-2/9)/p^2/(3*p-3*(-3*p^2+2*p+1 )^(1/2)+1)^3)^(5/2) The scaled , 6, -th moment about the mean is / |/ 160 1852 9 19498 8 7 505 11 1244 10 9352 6 - 576 ||- ----- + ---- p - ----- p + 35/3 p - --- p + ---- p + ---- p \\ 59049 243 729 27 81 2187 13189 5 25802 4 10360 3 640 2 1040 13 12 - ----- p - ----- p + ----- p + ----- p - ----- p + 1/3 p + 56/9 p 6561 59049 59049 59049 59049 5 4 10 3 \ 2 1/2 160 161063 p 2018 p 694 p 12760 p | (-3 p + 2 p + 1) + ----- + --------- + ------- - ------- - -------- / 59049 59049 6561 9 59049 2 13 9 8 7 6 80 p 400 p 14 17 p 20510 p 18247 p 40901 p 66043 p + ----- + ----- + p + ------ + -------- + -------- - -------- - -------- 59049 19683 9 729 729 2187 19683 12 11\ 209 p 1291 p | / 2 2 1/2 2 - ------- + --------| / ((p + 1/3) (-1 + p + (-3 p + 2 p + 1) ) 27 27 / / 2 1/2 2 (3 p - 3 (-3 p + 2 p + 1) + 1) 2 1/2 2 3 ((- p/3 + 2/9) (-3 p + 2 p + 1) + p + p/9 - 2/9) ) and in Maple format -576/(p+1/3)^2/(-1+p+(-3*p^2+2*p+1)^(1/2))^2*((-160/59049+1852/243*p^9-19498/ 729*p^8+35/3*p^7-505/27*p^11+1244/81*p^10+9352/2187*p^6-13189/6561*p^5-25802/ 59049*p^4+10360/59049*p^3+640/59049*p^2-1040/59049*p+1/3*p^13+56/9*p^12)*(-3*p^ 2+2*p+1)^(1/2)+160/59049+161063/59049*p^5+2018/6561*p^4-694/9*p^10-12760/59049* p^3+80/59049*p^2+400/19683*p+p^14+17/9*p^13+20510/729*p^9+18247/729*p^8-40901/ 2187*p^7-66043/19683*p^6-209/27*p^12+1291/27*p^11)/(3*p-3*(-3*p^2+2*p+1)^(1/2)+ 1)^2/((-1/3*p+2/9)*(-3*p^2+2*p+1)^(1/2)+p^2+1/9*p-2/9)^3 Let's check it against numerical computations and computer simulations for p=, 1/2 The exact value for these quantities are [3.236067977, 25.96919427, 5.303682260, 49.12407658, 613.3214132, 9732.326797] Let's see what happened after, 400, rounds The probability of ending in <=, 400, rounds is , 1.000000000 The approximate values for the average, variance, and higher scaled-moments \ about the mean are [3.236067977, 25.96919424, 5.303682175, 49.12406910, 613.3207996, 9732.276401] compared to the exact values [3.236067977, 25.96919427, 5.303682260, 49.12407658, 613.3214132, 9732.326797] Now let's run a simulation with, 1000, times (where you quit after, 400, rounds) The fraction of games that ended in <=, 400, rounds is 1. the statistical data for the simulation turned out to be [3.526000000, 35.27132400, 5.354954869, 44.59695326, 428.3912943, 4444.731117] Of course, this changes each time, but it is not too far off. recall that the exact value is [3.236067977, 25.96919427, 5.303682260, 49.12407658, 613.3214132, 9732.326797] This ends this article that took, 0.663, seconds to generate.