entering: Paper({[1,1/3]},{[1,2/3]}, 4,200,300,f,0.1): gives Statistical Analysis of the number of Rounds until you have at least ONE \ dollar In a Casino with a Certain Roulette By Shalosh B. Ekhad Once upon a time there was a casino with a strange roulette, where there were, 2, possible outcomes as follows. Regarding losing You lose, 1, dollars with probability, 1/3 Regarding winning You win, 1, dollars with probability, 2/3 You start with a capital of 0 dollars, and have unlimited credit. Your goal \ in life is to gain a POSITIVE amount, and you quit as soon as you reach that goal. Note that the expected gain in ONE round is, 1/3 Since it is positive, sooner or later you will reach your goal. The probability generating function, let's call it f=f(t), for the random va\ riable "duration of game" in other words, the formal power series whose coefficient of, t^n is the pro\ bability of ending after n rounds satisfies the following algebraic equation 2 f t - 3 f + 2 t = 0 and in Maple notation f^2*t-3*f+2*t = 0 The expected duration, let's call it, f[1], is one of the roots of the polynomial -(f[1] + 6) (f[1] - 3) and in Maple notation -(f[1]+6)*(f[1]-3) and its numerical value is 3. The second moment of the duration, let's call it, f[2], is one of the roots of the polynomial -(f[2] + 30) (f[2] - 33) and in Maple notation -(f[2]+30)*(f[2]-33) and its numerical value is 33. It follows that the variance is, 24.0 and hence the standard-deviation is, 4.8989794855663561964 The , 3, -th moment of the duration, let's call it, f[3], is one of the roots of the polynomial -(f[3] + 870) (f[3] - 867) and in Maple notation -(f[3]+870)*(f[3]-867) and its numerical value is 867. It follows that the scaled , 3, -th moment about the mean is, 5.3072277760302192129 The , 4, -th moment of the duration, let's call it, f[4], is one of the roots of the polynomial -(f[4] + 37182) (f[4] - 37185) and in Maple notation -(f[4]+37182)*(f[4]-37185) and its numerical value is 37185. It follows that the scaled , 4, -th moment about the mean is, 49.166666666666666667 To summarize the statistical data, expectation, variance, ... etc. is [3., 24.0, 5.3072277760302192129, 49.166666666666666667] Just to make sure, let's compare it with the much faster way of truncating t\ he prob. generating function up to, 200, rounds The corresponding approximation is [2.9999950916838696932, 23.998953034219750491, 5.3056654110325224897, 49.086591930828366308] and the probability that the goal is reached within, 200, rounds is , 0.99999997688087643618 Finally, let's compare it to the results of simulating it, 300, times. Of course this changes from time to time The corresponding crude approximation is [3.3266666666666666667, 64.306622222222222222, 10.600624983100489297, 146.26038947376556878] and the fraction of the simulated games that for which the goal was reached \ within, 200, rounds is , 1. So far we considered the Solitaire game. Now suppose that two players take t\ urns, and the first player to reach the goal of having positive capital is declared the winner. Assuming that th\ ey each are give at most, 200, turns the probability of the first-to-move player winning is 0.73653212009040252272 This ends this article that took, 0.351, seconds to generate. -------------------------- entering: Paper({[1,1/2]},{[2,1/2]}, 4,200,300,f,0.1): gives Statistical Analysis of the number of Rounds until you have at least ONE \ dollar In a Casino with a Certain Roulette By Shalosh B. Ekhad Once upon a time there was a casino with a strange roulette, where there were, 2, possible outcomes as follows. Regarding losing You lose, 1, dollars with probability, 1/2 Regarding winning You win, 2, dollars with probability, 1/2 You start with a capital of 0 dollars, and have unlimited credit. Your goal \ in life is to gain a POSITIVE amount, and you quit as soon as you reach that goal. Note that the expected gain in ONE round is, 1/2 Since it is positive, sooner or later you will reach your goal. The probability generating function, let's call it f=f(t), for the random va\ riable "duration of game" in other words, the formal power series whose coefficient of, t^n is the pro\ bability of ending after n rounds satisfies the following algebraic equation 2 3 2 2 t f - 4 f t + (3 t - 2 t + 4) f - 2 t = 0 and in Maple notation t^2*f^3-4*f^2*t+(3*t^2-2*t+4)*f-2*t = 0 The expected duration, let's call it, f[1], is one of the roots of the polynomial 2 -5 (f[1] + 6) (f[1] - 2 f[1] - 4) and in Maple notation -5*(f[1]+6)*(f[1]^2-2*f[1]-4) and its numerical value is 3.2360679774997896964 The second moment of the duration, let's call it, f[2], is one of the roots of the polynomial 2 -25 (f[2] + 34) (5 f[2] - 190 f[2] + 284) and in Maple notation -25*(f[2]+34)*(5*f[2]^2-190*f[2]+284) and its numerical value is 36.441330224498359632 It follows that the variance is, 25.969194269498780239 and hence the standard-deviation is, 5.0959978678860120024 The , 3, -th moment of the duration, let's call it, f[3], is one of the roots of the polynomial 2 -25 (f[3] + 990) (125 f[3] - 123250 f[3] - 232964) and in Maple notation -25*(f[3]+990)*(125*f[3]^2-123250*f[3]-232964) and its numerical value is 987.88656478025345561 It follows that the scaled , 3, -th moment about the mean is, 5.3036822588410593391 The , 4, -th moment of the duration, let's call it, f[4], is one of the roots of the polynomial 2 -25 (f[4] + 43954) (3125 f[4] - 137368750 f[4] + 276318524) and in Maple notation -25*(f[4]+43954)*(3125*f[4]^2-137368750*f[4]+276318524) and its numerical value is 43955.988398602753051 It follows that the scaled , 4, -th moment about the mean is, 49.124076510721174580 To summarize the statistical data, expectation, variance, ... etc. is [3.2360679774997896964, 25.969194269498780239, 5.3036822588410593391, 49.124076510721174580] Just to make sure, let's compare it with the much faster way of truncating t\ he prob. generating function up to, 200, rounds The corresponding approximation is [3.2360602819043127325, 25.967541106485928345, 5.3014897469298438762, 49.014781892180858605] and the probability that the goal is reached within, 200, rounds is , 0.99999996399784087099 Finally, let's compare it to the results of simulating it, 300, times. Of course this changes from time to time The corresponding crude approximation is [3.3933333333333333333, 26.105288888888888889, 3.7460330615789364504, 19.733183123840815889] and the fraction of the simulated games that for which the goal was reached \ within, 200, rounds is , 1. So far we considered the Solitaire game. Now suppose that two players take t\ urns, and the first player to reach the goal of having positive capital is declared the winner. Assuming that th\ ey each are give at most, 200, turns the probability of the first-to-move player winning is 0.66108609130528840090 This ends this article that took, 0.319, seconds to generate. -------------------------- entering: Paper({[1,1/2]},{[3,1/2]}, 2,200,300,f,0.1): gives Statistical Analysis of the number of Rounds until you have at least ONE \ dollar In a Casino with a Certain Roulette By Shalosh B. Ekhad Once upon a time there was a casino with a strange roulette, where there were, 2, possible outcomes as follows. Regarding losing You lose, 1, dollars with probability, 1/2 Regarding winning You win, 3, dollars with probability, 1/2 You start with a capital of 0 dollars, and have unlimited credit. Your goal \ in life is to gain a POSITIVE amount, and you quit as soon as you reach that goal. Note that the expected gain in ONE round is, 1 Since it is positive, sooner or later you will reach your goal. The probability generating function, let's call it f=f(t), for the random va\ riable "duration of game" in other words, the formal power series whose coefficient of, t^n is the pro\ bability of ending after n rounds satisfies the following algebraic equation 3 4 2 3 3 2 2 2 3 2 t f - 6 t f + (6 t - 6 t + 12 t) f + (-10 t + 8 t - 8) f + t - 2 t + 4 t = 0 and in Maple notation t^3*f^4-6*t^2*f^3+(6*t^3-6*t^2+12*t)*f^2+(-10*t^2+8*t-8)*f+t^3-2*t^2+4*t = 0 The expected duration, let's call it, f[1], is one of the roots of the polynomial 3 -11 (f[1] + 6) (f[1] - 4 f[1] - 4) and in Maple notation -11*(f[1]+6)*(f[1]^3-4*f[1]-4) and its numerical value is 2.3829757679062374941 The second moment of the duration, let's call it, f[2], is one of the roots of the polynomial 3 2 -121 (f[2] + 10) (11 f[2] - 176 f[2] + 456 f[2] - 364) and in Maple notation -121*(f[2]+10)*(11*f[2]^3-176*f[2]^2+456*f[2]-364) and its numerical value is 13.008908656889700167 It follows that the variance is, 7.3303351464613779020 and hence the standard-deviation is, 2.7074591680136891590 To summarize the statistical data, expectation, variance, ... etc. is [2.3829757679062374941, 7.3303351464613779020] Just to make sure, let's compare it with the much faster way of truncating t\ he prob. generating function up to, 200, rounds The corresponding approximation is [2.3829757679045946731, 7.3303351461240067456] and the probability that the goal is reached within, 200, rounds is , 0.99999999999999199180 Finally, let's compare it to the results of simulating it, 300, times. Of course this changes from time to time The corresponding crude approximation is [2.4900000000000000000, 8.2499000000000000000] and the fraction of the simulated games that for which the goal was reached \ within, 200, rounds is , 1. So far we considered the Solitaire game. Now suppose that two players take t\ urns, and the first player to reach the goal of having positive capital is declared the winner. Assuming that th\ ey each are give at most, 200, turns the probability of the first-to-move player winning is 0.66542479602204105091 This ends this article that took, 0.204, seconds to generate. -------------------------- entering Paper({[1,1/4],[2,3/8]},{[1,1/4],[2,1/8]}, 2,200,300,f,0.1): give\ s Statistical Analysis of the number of Rounds until you have at least ONE \ dollar In a Casino with a Certain Roulette By Shalosh B. Ekhad Once upon a time there was a casino with a strange roulette, where there were, 4, possible outcomes as follows. Regarding losing You lose, 1, dollars with probability, 1/4 You lose, 2, dollars with probability, 3/8 Regarding winning You win, 1, dollars with probability, 1/4 You win, 2, dollars with probability, 1/8 You start with a capital of 0 dollars, and have unlimited credit. Your goal \ in life is to gain a POSITIVE amount, and you quit as soon as you reach that goal. Note that the expected gain in ONE round is, -1/2 Since it is negative, you may not be able to reach your goal. The probability generating function, let's call it f=f(t), for the random va\ riable "duration of game" in other words, the formal power series whose coefficient of, t^n is the pro\ bability of ending after n rounds satisfies the following algebraic equation 3 6 3 2 5 3 2 4 27 t f + (54 t - 72 t ) f + (93 t - 240 t ) f 3 2 3 3 2 2 + (164 t - 272 t + 384 t) f + (53 t - 672 t + 448 t) f 3 2 3 2 + (134 t - 104 t + 512 t - 512) f - 13 t - 176 t + 192 t = 0 and in Maple notation 27*t^3*f^6+(54*t^3-72*t^2)*f^5+(93*t^3-240*t^2)*f^4+(164*t^3-272*t^2+384*t)*f^3 +(53*t^3-672*t^2+448*t)*f^2+(134*t^3-104*t^2+512*t-512)*f-13*t^3-176*t^2+192*t = 0 The probability of reaching your goal let's call it, f[0], is one of the roots of the polynomial 3 2 3 3 (9 f[0] + 21 f[0] - 13 f[0] - 1) (f[0] - 1) and in Maple notation 3*(9*f[0]^3+21*f[0]^2-13*f[0]-1)*(f[0]-1)^3 and its numerical value is 0.56592947833381131987 The (unconditoinal) expected duration, let's call it, f[1], is one of the roots of the polynomial 3 2 -303 (909 f[1] - 6060 f[1] + 10192 f[1] - 4448) 3 2 (3 f[1] + 28 f[1] + 64 f[1] + 32) and in Maple notation -303*(909*f[1]^3-6060*f[1]^2+10192*f[1]-4448)*(3*f[1]^3+28*f[1]^2+64*f[1]+32) and its numerical value is 1.6303428615449941582 The second moment of the (unconditoinal) duration (before conditioning on su\ ccess), let's call it, f[2], is one of the roots of the polynomial 3 2 -275427 (1030301 f[2] - 61818060 f[2] + 764874032 f[2] + 354282976) 3 2 (303 f[2] + 17372 f[2] + 207648 f[2] - 95904) and in Maple notation -275427*(1030301*f[2]^3-61818060*f[2]^2+764874032*f[2]+354282976)*(303*f[2]^3+ 17372*f[2]^2+207648*f[2]-95904) and its numerical value is 18.220831999435959053 It follows that the (CONDITIONED upon success) variance is, 23.897150998724510176 and hence the standard-deviation is, 4.8884712332921127844 The probability that you would reach your goal is, 0.56592947833381131987 and the statistical data, expectation, variance, ... etc. is [2.8808233604388119715, 23.897150998724510176] Just to make sure, let's compare it with the much faster way of truncating t\ he prob. generating function up to, 200, rounds The corresponding approximation is [2.8808113196266128069, 23.894557010628739948] and the probability that the goal is reached within, 200, rounds is , 0.56592944652695394289 Finally, let's compare it to the results of simulating it, 300, times. Of course this changes from time to time The corresponding crude approximation is [2.2339181286549707602, 9.9335864026538080093] and the fraction of the simulated games that for which the goal was reached \ within, 200, rounds is , 0.57000000000000000000 This ends this article that took, 3.734, seconds to generate. -------------------------- entering Paper({[1,1/4],[2,3/8]},{[1,1/4],[2,1/8]}, 2,200,300,f,0.1): give\ s Statistical Analysis of the number of Rounds until you have at least ONE \ dollar In a Casino with a Certain Roulette By Shalosh B. Ekhad Once upon a time there was a casino with a strange roulette, where there were, 4, possible outcomes as follows. Regarding losing You lose, 1, dollars with probability, 1/4 You lose, 2, dollars with probability, 1/8 Regarding winning You win, 1, dollars with probability, 1/4 You win, 2, dollars with probability, 3/8 You start with a capital of 0 dollars, and have unlimited credit. Your goal \ in life is to gain a POSITIVE amount, and you quit as soon as you reach that goal. Note that the expected gain in ONE round is, 1/2 Since it is positive, sooner or later you will reach your goal. The probability generating function, let's call it f=f(t), for the random va\ riable "duration of game" in other words, the formal power series whose coefficient of, t^n is the pro\ bability of ending after n rounds satisfies the following algebraic equation 3 6 3 2 5 3 2 4 3 2 3 t f + (6 t - 8 t ) f + (19 t - 48 t ) f + (84 t - 80 t + 128 t) f 3 2 2 3 2 3 + (71 t - 608 t + 320 t) f + (262 t - 360 t + 768 t - 512) f + 69 t 2 - 432 t + 320 t = 0 and in Maple notation t^3*f^6+(6*t^3-8*t^2)*f^5+(19*t^3-48*t^2)*f^4+(84*t^3-80*t^2+128*t)*f^3+(71*t^3 -608*t^2+320*t)*f^2+(262*t^3-360*t^2+768*t-512)*f+69*t^3-432*t^2+320*t = 0 The expected duration, let's call it, f[1], is one of the roots of the polynomial 3 2 -101 (101 f[1] + 2020 f[1] + 5344 f[1] - 7968) 3 2 (f[1] - 12 f[1] + 16 f[1] + 32) and in Maple notation -101*(101*f[1]^3+2020*f[1]^2+5344*f[1]-7968)*(f[1]^3-12*f[1]^2+16*f[1]+32) and its numerical value is 2.9653919099833889487 The second moment of the duration, let's call it, f[2], is one of the roots of the polynomial 3 2 -10201 (1030301 f[2] + 135999732 f[2] + 3414225408 f[2] + 2560353184) 3 2 (101 f[2] - 14140 f[2] + 367216 f[2] - 273824) and in Maple notation -10201*(1030301*f[2]^3+135999732*f[2]^2+3414225408*f[2]+2560353184)*(101*f[2]^3 -14140*f[2]^2+367216*f[2]-273824) and its numerical value is 33.317997349437264261 It follows that the variance is, 24.524448169642332716 and hence the standard-deviation is, 4.9522164905870515382 To summarize the statistical data, expectation, variance, ... etc. is [2.9653919099833889487, 24.524448169642332716] Just to make sure, let's compare it with the much faster way of truncating t\ he prob. generating function up to, 200, rounds The corresponding approximation is [2.9653794731370811254, 24.521769946641356610] and the probability that the goal is reached within, 200, rounds is , 0.99999994192561441291 Finally, let's compare it to the results of simulating it, 300, times. Of course this changes from time to time The corresponding crude approximation is [3.0366666666666666667, 24.101988888888888889] and the fraction of the simulated games that for which the goal was reached \ within, 200, rounds is , 1. So far we considered the Solitaire game. Now suppose that two players take t\ urns, and the first player to reach the goal of having positive capital is declared the winner. Assuming that th\ ey each are give at most, 200, turns the probability of the first-to-move player winning is 0.70505142526109311635 This ends this article that took, 2.209, seconds to generate.