Question

In: Math

Regarding problem R2 from chapter 26. Make a box representing a roulette wheel with 18 tickets...

Regarding problem R2 from chapter 26. Make a box representing a roulette wheel with 18 tickets that represent red and 20 that represent black or green. Draw 3800 times with replacement from this box and record the number of tickets drawn that are red. Repeat this process 10,000 times. What is the fraction of times (out of these 10,000 repeated trials) were the number of red tickets drawn at least 1,890? How does this compare to the P-value you got in the problem? Can you use pbinom( ) to compute this probability? Are these numbers different? Why?

"With a perfectly balanced roulette wheel, in the long run, red numbers should turn up 18 times in 38. To test its wheel, one casino records the results of 3800 plays finding 1890 reds numbers.Is that too many reds. Or chance variation?"

How do I compute this on R?

Solutions

Expert Solution

Following R-Script can be run in R console to do this simulation as:

---------------------------------------------

## Let us take a vector 'choice' that contains 18 Reds, 20 Green or Black as
choice <- c(rep('R', 18), rep(c('G', 'B'), 10))

## Simulate the draws of a ticket from choice using sampling with replacement with 10000 replication.
# Assign number of the replication ('repl') in the simulation. Each column consists separate 3800 draws
repl <- 10000
draw <- as.data.frame(replicate(repl, sample(choice, size = 3800, replace = T)))

## Gather the number of 'Reds' in each column (3800 draws) in the vector 'red.count'.
red.count <- c()
for(i in 1:repl){
red.count[i] <- sum(draw[[i]] == 'R')
}

## Fraction of cases 'f' when number of 'Reds' is at least 1890
(f <- (sum(red.count >= 1890))/repl)

---------------------------------------------

This p-value can be calculated using ‘pbinom()’ function as:

---------------------------------------------

## Using 'pbinom' function to see the probability of getting atleast 1890 'Reds' in 3800 trials
(prob <- 1 - pbinom(1890, size = 3800, prob = 18/38))

--------------------------------------------

Output:

0.001648493

If we compare this p-value with calculated ‘f’ in the script, we can see the values will be closed by, al though little different.

Obviously, during simulation we take random numbers following some constraints and try to find probability distribution and hence the values differ from the most accurate value.

Here, every time run the script, we can see the ‘f’ value will be some times 0.00123, 0.00167, 0.0014 or sometimes 0.0023, 0.0027 etc. in 10000 number of replications in the simulation. As we increase the number of replication by 100 or 200, these ‘f’ values will become more and more consistent and closed to the p-value 0.001648 given by the ‘pbinom()’ function.

According to usage of Binomial distribution in R, following R-command can give probability to get exactly 1890 ‘Reds’ in 3800 number of trials as:

--------------------------------------------

## Probability to see exactly 1890 'Reds' in 3800 number of trials:
dbinom(1890, size = 3800, prob = 18/38)

--------------------------------------------

Output:

0.0001810551

That means there is only 0.018% chance to see exactly 1890 Reds in 3800 numbers of plays. In other way we can say that in 10000 runs (replications) of 3800 number of plays (trials), this same thing can happen only 1.81 ~ 2 times. So, we can say that this is a chance variation.

N.B. Please DO NOT try to see the data.frame 'draw' within R console. We will not be able to understand the simulation result. Rather use the command: View(draw) to see the simulated 3800 trials in 10000 replications.

DO NOT increase the number replication 'repl' too much at a time, machine can hang/'slow down'.


Related Solutions

Task 1: Roulette wheel simulation A roulette wheel has 38 slots of which 18 are red,...
Task 1: Roulette wheel simulation A roulette wheel has 38 slots of which 18 are red, 18 are black, and 2 are green. If a ball spun on to the wheel stops on the color a player bets, the player wins. Consider a player betting on red. Winning streaks follow a Geometric(p = 20/38) distribution in which we look for the number of red spins in a row until the first black or green. Use the derivation of the Geometric...
STRAIGHT FROM THE BOOK Roulette In the casino game of roulette there is a wheel with...
STRAIGHT FROM THE BOOK Roulette In the casino game of roulette there is a wheel with 19 black slots, 19 red slots, and 2 green slots. In the game, a ball is rolled around a spinning wheel and it lands in one of the slots. It is assumed that each slot has the same probability of getting the ball. This results in the table of probabilities below. Fair Table Probabilities   black     red     green   Probability   19/40 19/40 2/40 You watch the...
A roulette wheel is divided into 38 labeled pockets, 18 of which are red, 18 are...
A roulette wheel is divided into 38 labeled pockets, 18 of which are red, 18 are black, and 2 are green. Each round, you can place a $1 bet on one specific red or black pocket with odds of 35 : 1. That is, if you are correct you receive $35 in addition to the dollar you bet, and if you are incorrect, you get nothing. Your friend has developed what he describes as a “foolproof system” for winning. It...
The game of roulette involves spinning a wheel with 38 slots: 18 red, 18 black, and...
The game of roulette involves spinning a wheel with 38 slots: 18 red, 18 black, and 2 green. A ball is spun onto the wheel and will eventually land in a slot, where each slot has an equal chance of capturing the ball. (a) You watch a roulette wheel spin 4 consecutive times and the ball lands on a black slot each time. What is the probability that the ball will land on a block slot on the next spin?...
In the game of roulette, a steel ball is rolled onto a wheel that contains 18...
In the game of roulette, a steel ball is rolled onto a wheel that contains 18 red, 18 black, and 2 green slots. If the ball is rolled 38 times, find the probability of the following events. A. The ball falls into the green slots 3 or more times. Probability = (0.3815 is the wrong answer) B. The ball does not fall into any green slots. Probability = (0.2590 is wrong) C. The ball falls into black slots 14 or...
In the game of roulette, a steel ball is rolled onto a wheel that contains 18...
In the game of roulette, a steel ball is rolled onto a wheel that contains 18 red, 18 black, and 2 green slots. If the ball is rolled 38 times, find the probability of the following events. A. The ball falls into the green slots 4 or more times. B. The ball does not fall into any green slots. C. The ball falls into black slots 15 or more times. D. The ball falls into red slots 10 or fewer...
A roulette wheel has 38 slots, 18 of which are black, 18 red, and 2 green....
A roulette wheel has 38 slots, 18 of which are black, 18 red, and 2 green. When the wheel is spun, the ball is equally likely to land in any of the 38 slots. Gamblers can place a number of different bets in roulette. One of the simplest wagers chooses red or black. A bet of $1 on red will pay off an additional dollar if the ball lands in a red slot. Otherwise, the player loses the original dollar....
The American roulette wheel has 38 total slots of which 18 are colored red, 18 are...
The American roulette wheel has 38 total slots of which 18 are colored red, 18 are colored black, and 2 are colored green. The red and the black slots are numbered 1 through 36. The green slots are numbered 0 and 00. Construct the probability distribution for betting $1 on the second dozen numbers, 13 through 24, (which pays 2 to 1) in the game of roulette and calculate the corresponding mean and standard deviation.
A roulette wheel has 38 slots: 18 red, 18 black, and 2 green. A ball is...
A roulette wheel has 38 slots: 18 red, 18 black, and 2 green. A ball is tossed into the wheel and eventually settles in a slot at random. You play many games, betting $1 on red each time. If the ball lands in a red slot you win $1, otherwise you lose the dollar you bet. After n games, what is the probability that you have more money than you started with? Give (approximate) numerical answers for n = 100...
2. (Binomial model) Consider a roulette wheel with 38 slots, of which 18 are red, 18...
2. (Binomial model) Consider a roulette wheel with 38 slots, of which 18 are red, 18 are black, and 2 are green (0 and 00). You spin the wheel 6 times. (a) What is the probability that 2 of those times the ball ends up in a green slot? ( b) What is the probability that 4 of those times the ball ends up in a red slot? 3. (Normal approximation to binomial model) Take the roulette wheel from question...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT