Tcl Library Source Code

View Ticket
Login
Ticket UUID: e056ba311675e31fe131223c5e47394008133b49
Title: Gamblers_Ruin_Expectation as Probability in TCLLIB math
Type: Patch Version: 8.6
Submitter: anonymous Created on: 2021-09-19 13:34:34
Subsystem: math :: special Assigned To: arjenmarkus
Priority: 5 Medium Severity: Cosmetic
Status: Open Last Modified: 2022-05-02 07:22:14
Resolution: None Closed By: nobody
    Closed on:
Description:
Subject:  Gamblers_Ruin_Expectation as Probability  in TCLLIB math

Request Gamblers_Ruin_Expectation as Probability. 

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
User Comments: arjenmarkus added on 2022-05-02 07:22:14:
There appears to be quite a bit more to this topic, see for instance https://towardsdatascience.com/the-gamblers-ruin-problem-9c97a7747171. 

I am going to see whether it is useful to adopt some of the ideas described there :).

Attachments: