Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Carefully read the R code for the simulation of Craps game; the code is bellow . Modify the code to include the stopping times (i.e.,

  1. Carefully read the R code for the simulation of Craps game; the code is bellow . Modify the code to include the stopping times (i.e., the total numbers of trials) to stop (win or lose) the game. Run a simulation for at least 10,000 runs. Report the results of your simulation: (a) what is the estimate of the probability of winning? (b) Obtain a "LLN type" of plot to visualize how the sequence of partial fractions converge to the theoretical probability of winning? (c) Obtain a histogram of the stopping times and what is the estimated average number of trials to stop the game?

The code:

##### Two pairs - Poker Game

## Consider poker games, the player is dealt five cards, a two-pairs is two cards showing the same numbers and## another two cardsshowing the same numbers (but not all four numbers the same) plus one extra card (not the ## same as any of the other numbers).

# Exact probability = 123552/2598960 = 0.047539

choose(13,2)*(choose(4,2)^2)*choose(11,1)*choose(4,1)/choose(52,5)

# = 123552/2598960 = 0.04753902

# Simulation

set.seed(7628)

n <- 100000

simlist <- numeric(n)

deck <- rep(1:13, times = 4)

for (i in 1:n) {

cards.hands <- sample(deck,5,replace=FALSE)

# use table() to get frequencies of each card

t.hands <- table(cards.hands)

success <- if (sum(t.hands==2)==2) 1 else 0

simlist[i] <- success }

mean(simlist)

# [1] 0.04783

## LLN plot

p.2pairs <- cumsum(simlist)/(1:n)

plot(p.2pairs, type = 'l', ylim= c(0.03, 0.06),

xlab= expression(italic(n)), ylab= expression(italic(p.2pairs)))

abline(h = 0.047539, col="blue")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Step: 3

blur-text-image

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

Non-Cooperative Game Theory

Authors: Takako Fujiwara Greve

1st Edition

4431556451, 9784431556459

More Books

Students also viewed these Mathematics questions

Question

1. What is the meaning of the information we are collecting?

Answered: 1 week ago

Question

3. How much information do we need to collect?

Answered: 1 week ago

Question

2. What types of information are we collecting?

Answered: 1 week ago