Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simulate gamblers ruin for a gambler with initial stake $2, playing a fair game. (a) Estimate the probability that the gambler is ruined before he

Simulate gambler’s ruin for a gambler with initial stake $2, playing a fair game.

(a) Estimate the probability that the gambler is ruined before he wins $5.

(b) Construct the transition matrix for the associated Markov chain. Estimate the desired probability in (a) by taking high matrix powers.

(c) Compare your results with the exact probability.

The R code for gambler's ruin is:

# gamblersruin.R
# Example 1.11

# gamble(k, n, p)
  #   k: Gambler's initial state
  #   n: Gambler plays until either $n or Ruin
  #   p: Probability of winning $1 at each play
  #   Function returns 1 if gambler is eventually ruined
  #                    returns 0 if gambler eventually wins $n
 
gamble <- function(k,n,p) {
        stake <- k
        while (stake > 0 & stake < n) {
                bet <- sample(c(-1,1),1,prob=c(1-p,p))
                stake <- stake + bet
        }
        if (stake == 0) return(1) else return(0)
        }  

k <- 10
n <-  40  
p <- 1/2  
trials <- 1000
simlist <- replicate(trials, gamble(k, n, p))
mean(simlist) # Estimate of probability that gambler is ruined
# For p = 0.5, exact probability is (n-k)/n

Step by Step Solution

3.57 Rating (154 Votes )

There are 3 Steps involved in it

Step: 1

Required solution Ans a Using 1000 simulation k n p trials simlist meansimlist Estimate of probability that gambler is ruined 1 059 Ans b Markov chain ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

A Pathway To Introductory Statistics

Authors: Jay Lehmann

1st Edition

0134107179, 978-0134107172

More Books

Students also viewed these Accounting questions

Question

The domain of the variable in the expression x 3/x + 4 is________.

Answered: 1 week ago