Tcl Library Source Code

Artifact [ab364c2243]
Login

Artifact ab364c22430b57a74606a28217cbba3e3c6e75ff4a3dc39d670c1119a16bd3af:

Attachment "Gamblers_Ruin_Expectation as Probability.txt" to ticket [e056ba3116] added by anonymous 2021-09-19 13:35:54. (unpublished)
Subject:  Gamblers_Ruin_Expectation as Probability

Request Gamblers_Ruin_Expectation as Probability in TCLLIB math.

As an example from a wildly different subject, the Gamblers Ruin Expectation E(P(N)). As defined here, expectation E(P(N)) is the combined probability over 1 or more games with a constant win probability for each game. The example here is 50 percent chance of winning for each game and complement percentage for losing. The Expectation E(P(N)) or Gamblers chance of going broke after N successive games is E(P(N)) = < 0.5 + 0.25 + 0.125 + . . Nth game >. The E(P(N) formula over the total games until finish is formula E(P(N)) = xpr {1. - (1./2.)^*$N} . The more games, the closer the E(P(N)) approaches 1. The Expectation E(P(N) for an infinte set of games is 1, meaning a dead loss over all total games. Check for 1 game is expr {0.5 } returns 0.5. Check for 2 games is expr {0.5 + 0.25 } returns 0.75Check for 3 games is expr {0.5 + 0.25 + 0.125 } returns 0.875 and expr { 1. - (1./2.)**3. } returns 0.875. Check for 4 games is expr { 1. - (1./2.)**4. } returns 0.9375. The Gamblers Expectation of win over all games or original flush state at E(P(N)) = 0' is not expected here, but still can not be ruled out. Thank You.
------------
Updating Refs on wiki page, Collatz_Sequences (3*N+1) in Console Example Demo for TCL V3, https://wiki.tcl-lang.org/page/Collatz_Sequences+%283%2AN%2B1%29+in+Console+Example+Demo+for+TCL+V3+?V=99

Sample Code 
        proc Gamblers_Ruin_Expectation {games probability_win} {
            if { $games <1 } {
                return -code error "The games must be 1 or larger "
            }
            expr {(1.-($probability_win**$games))}       }
              # game  1 0.5 returns   0.5 
              # game  2 0.5 returns  0.75 
              # game 3 0.5 returns  0.875 
              # game  4 0.5 returns  0.9375 
              # game  3   .14  returns 0.997256