Tcl Library Source Code

Artifact [c02fedaa46]
Login

Artifact c02fedaa465bd93ba6af539b952448ac57b919e334d4e864c3ea09fa0ba53c08:

Ticket change [c02fedaa46] - Add attachment [/artifact/ab364c22430b57a7|Gamblers_Ruin_Expectation as Probability.txt] to ticket [e056ba311675e31f|e056ba3116] by anonymous 2021-09-19 13:35:54.
A Gamblers_Ruin_Expectation\sas\s\sProbability.txt e056ba311675e31fe131223c5e47394008133b49 ab364c22430b57a74606a28217cbba3e3c6e75ff4a3dc39d670c1119a16bd3af
C Request\sGamblers_Ruin_Expectation\sas\sProbability\sin\sTCLLIB\smath.\r\n\r\nAs\san\sexample\sfrom\sa\swildly\sdifferent\ssubject,\sthe\sGamblers\sRuin\sExpectation\sE(P(N)).\sAs\sdefined\shere,\sexpectation\sE(P(N))\sis\sthe\scombined\sprobability\sover\s1\sor\smore\sgames\swith\sa\sconstant\swin\sprobability\sfor\seach\sgame.\sThe\sexample\shere\sis\s50\spercent\schance\sof\swinning\sfor\seach\sgame\sand\scomplement\spercentage\sfor\slosing.\sThe\sExpectation\sE(P(N))\sor\sGamblers\schance\sof\sgoing\sbroke\safter\sN\ssuccessive\sgames\sis\sE(P(N))\s=\s<\s0.5\s+\s0.25\s+\s0.125\s+\s.\s.\sNth\sgame\s>.\sThe\sE(P(N)\sformula\sover\sthe\stotal\sgames\suntil\sfinish\sis\sformula\sE(P(N))\s=\sxpr\s{1.\s-\s(1./2.)^*$N}\s.\sThe\smore\sgames,\sthe\scloser\sthe\sE(P(N))\sapproaches\s1.\sThe\sExpectation\sE(P(N)\sfor\san\sinfinte\sset\sof\sgames\sis\s1,\smeaning\sa\sdead\sloss\sover\sall\stotal\sgames.\sCheck\sfor\s1\sgame\sis\sexpr\s{0.5\s}\sreturns\s0.5.\sCheck\sfor\s2\sgames\sis\sexpr\s{0.5\s+\s0.25\s}\sreturns\s0.75Check\sfor\s3\sgames\sis\sexpr\s{0.5\s+\s0.25\s+\s0.125\s}\sreturns\s0.875\sand\sexpr\s{\s1.\s-\s(1./2.)**3.\s}\sreturns\s0.875.\sCheck\sfor\s4\sgames\sis\sexpr\s{\s1.\s-\s(1./2.)**4.\s}\sreturns\s0.9375.\sThe\sGamblers\sExpectation\sof\swin\sover\sall\sgames\sor\soriginal\sflush\sstate\sat\sE(P(N))\s=\s0'\sis\snot\sexpected\shere,\sbut\sstill\scan\snot\sbe\sruled\sout.\sThank\sYou.\r\n------------\r\nUpdating\sRefs\son\swiki\spage,\sCollatz_Sequences\s(3*N+1)\sin\sConsole\sExample\sDemo\sfor\sTCL\sV3,\shttps://wiki.tcl-lang.org/page/Collatz_Sequences+%283%2AN%2B1%29+in+Console+Example+Demo+for+TCL+V3+?V=99\r\n\r\nSample\sCode\s\r\n\s\s\s\s\s\s\s\sproc\sGamblers_Ruin_Expectation\s{games\sprobability_win}\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\sif\s{\s$games\s<1\s}\s{\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s\s\sreturn\s-code\serror\s"The\sgames\smust\sbe\s1\sor\slarger\s"\r\n\s\s\s\s\s\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\s\s\s\s\sexpr\s{(1.-($probability_win**$games))}\s\s\s\s\s\s\s}\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s#\sgame\s\s1\s0.5\sreturns\s\s\s0.5\s\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s#\sgame\s\s2\s0.5\sreturns\s\s0.75\s\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s#\sgame\s3\s0.5\sreturns\s\s0.875\s\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s#\sgame\s\s4\s0.5\sreturns\s\s0.9375\s\r\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s#\sgame\s\s3\s\s\s.14\s\sreturns\s0.997256
D 2021-09-19T13:35:54.824
U anonymous
Z cdbb90b401beb2f9c76df151b146ec43