Where Did the Monte Carlo Simulation Go Wrong?

Click For Summary
SUMMARY

The Monte Carlo simulation for the game involving the selection of two numbers from the set {1,2,3,4,5} yielded inconsistent results compared to the analytical solution. The probability of winning in a single game was calculated as 0.6, leading to an expected profit of -$340 after 17 games. However, the R simulation produced an expected profit of -$480.38, indicating a potential error in the simulation code or assumptions regarding sampling methods. Clarification on whether the selection is with or without replacement is crucial for accurate probability calculations.

PREREQUISITES
  • Understanding of probability theory, specifically binomial distributions.
  • Familiarity with Monte Carlo simulation techniques.
  • Proficiency in R programming for statistical analysis.
  • Knowledge of expected value and variance calculations.
NEXT STEPS
  • Review R programming for Monte Carlo simulations, focusing on sampling methods.
  • Study binomial distributions and their applications in probability calculations.
  • Learn about variance and expected value in the context of gambling scenarios.
  • Explore the implications of sampling with and without replacement in probability theory.
USEFUL FOR

Mathematicians, statisticians, data analysts, and anyone interested in understanding the discrepancies between analytical and simulation-based probability calculations.

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
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
1
Views
697
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
1
Views
3K