MHB Where Did the Monte Carlo Simulation Go Wrong?

Lancelot1
Messages
26
Reaction score
0
Two numbers are bring chosen by random from the set {1,2,3,4,5}. If the sum of the two numbers is even, you win 100 dollars, otherwise you win nothing. In order to participate in the game, you pay $80. What is the expected value and variance of the profit after 17 games ?

I solved this one analytically and with Monte Carlo simulation and got different results, I wonder where my mistake it.

The Solution:

The probability of success in a single game is:

\[p=\frac{\binom{2}{2}\binom{3}{0}+\binom{2}{0}\binom{3}{2}}{\binom{5}{2}}=0.6\]

If we define X to be the number of successes, then

\[X:Bin(17,0.6)\]

Therefore:

\[E(X)=10.2, V(X)=4.08\]

The profit is a linear transformation of X:

\[Y=100X-1360\]

And thus:

\[E(Y)=100\cdot 10.2-1360=-340\]

\[V(Y)=10000\cdot 4.08=40800\]My R code is below, and it yields different results , e.g.:

\[E(Y)=-480.38 ... V(Y)=10000\cdot 4.08=42751.21\]

where is the mistake ?

n = 5000
successes = rep(0,n)
for (j in 1:n)
{
result = rep(0,17)
for (i in 1:17)
{
game.result = sample(1:5,2,replace = T)
if (sum(game.result)%%2==0)
{
result = 1
}
}
successes[j] = sum(result)
}
successes
mean(successes)
var(successes)

profit = 100*successes-1360
mean(profit)
var(profit)
 
Physics news on Phys.org
Please clarify- when you "choose two numbers from the set", can you choose the same number twice? That is, is this "sampling with replacement" or "sampling without replacement?

If it is the first, then there are 25 possible outcomes. The probability of odd on each pick is 3/5, the probability of even is 2/5. In order that the sum of the two numbers be even, both choices must be even, which has probability 4/25, or both choice odd which has probability 9/25. The probability of winning in anyone game is 4/25+ 9/25= 13/25. The expected winning in anyone game is (13/25)(100)= $52. You had to pay $80 to pay so you can expect to lose $28 on each game.

The other, sampling without replacement, is slightly harder. The probability you draw an even number the first time is still 2/5 but now there are 4 numbers to pick from with only one even. The probability you also draw an even number the second time is 1/4 so the probability you draw two even numbers, and win, is (2/5)(1/4)= 1/10. The probability you draw an odd number the first time is 3/5. Now there are 4 numbers to pick from, 2 odd. The probability you draw an odd number the second time is 2/4= 1/2 so the probability you draw two odd numbers, and win, is (3/5)(1/2)= 3/10. The expected value now is (3/10)(100)= $30. You had to pay $80 to play so your expected loss is $50.the second, 20 possible outcomes. In the f
 
Hi all, I've been a roulette player for more than 10 years (although I took time off here and there) and it's only now that I'm trying to understand the physics of the game. Basically my strategy in roulette is to divide the wheel roughly into two halves (let's call them A and B). My theory is that in roulette there will invariably be variance. In other words, if A comes up 5 times in a row, B will be due to come up soon. However I have been proven wrong many times, and I have seen some...
Thread 'Detail of Diagonalization Lemma'
The following is more or less taken from page 6 of C. Smorynski's "Self-Reference and Modal Logic". (Springer, 1985) (I couldn't get raised brackets to indicate codification (Gödel numbering), so I use a box. The overline is assigning a name. The detail I would like clarification on is in the second step in the last line, where we have an m-overlined, and we substitute the expression for m. Are we saying that the name of a coded term is the same as the coded term? Thanks in advance.
Back
Top