- #1
Lancelot1
- 28
- 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)
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)