What is the Winning Probability in Monte Carlo Spinner Game?

  • Context: Python 
  • Thread starter Thread starter Arman777
  • Start date Start date
  • Tags Tags
    Monte carlo Spin
Click For Summary

Discussion Overview

The discussion revolves around a Monte Carlo simulation problem involving a game with two spinner disks. Participants explore how to calculate the winning probability for a player starting with disk 1, based on specific rules governing the game's mechanics. The conversation includes code snippets and attempts to identify errors in the simulation results.

Discussion Character

  • Exploratory
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant presents a Monte Carlo simulation code to estimate the winning probability, expecting a result of 0.5821 but obtaining 0.655 instead.
  • Another participant questions the validity of the claimed correct answer and suggests using a random seed for consistency in results.
  • Several participants express concerns that the original code does not accurately reflect the game's rules, suggesting that it oversimplifies the mechanics and fails to account for conditional probabilities.
  • A participant proposes a revised code structure that better captures the game's dynamics, indicating that the game resembles a Markov process and requires consideration of all possible paths to a win.
  • One participant claims to have resolved the issue with their code, asserting that the correct winning probability is actually 0.65, contradicting the previously stated expected result.

Areas of Agreement / Disagreement

Participants express differing views on the correctness of the original code and the expected winning probability. While some agree on the need for a more accurate simulation, there is no consensus on the correct winning probability, as claims vary between 0.5821 and 0.65.

Contextual Notes

The discussion highlights potential limitations in the original code, including assumptions about the game's mechanics and the handling of probabilities. There are unresolved questions about the definitions and rules governing the game, which may affect the accuracy of the simulations.

Arman777
Insights Author
Gold Member
Messages
2,163
Reaction score
191
Problem:
Here’s a little Monte Carlo challenge problem, Consider the following game, which uses the two spinner disks. Suppose a player spins one or the other of the pointers on the disks according to the following rules: (1) if the player spins pointer ##i## and it stops in the region with area ##p_{ij}##, he moves from disk ##i## to disk ##j## (i and j are either 1 or 2); (2) if a pointer stops in the region with area ##x_i##, the game ends; (3) if the game ends in the region with area ##x_1##, the player wins, but if the pointer stops in the region with area ##x_2## the player loses. What is the probability the player, starting with disk 1, wins? Assume the area of each disk is one, so that ##x_1+p_{11}+p_{12} =1##, as well as that ##x_2+p_{21}+p_{22} =1##

Run your code for the case of ##p_{11} =0.2, p_{12} =0.4, p_{21} =0.3##, and ##p_{22} =0.35##.
Mentor note: Changed ICODE tags to code=python

243941

Python:
import random
    p_11 = 0.2
    p_12 = 0.4 #0.2+0.4
    p_21 = 0.3
    p_22 = 0.35    P_1 = p_11+p_12
    P_2 = p_21+p_22    #from starting 1:

    wins = 0
    num = 0
    for i in range(10**7):
        while num < P_1:
            num = random.uniform(0,1)
            if P_1 < num < 1:  #area corresponding to x_1
                wins += 1  #wins
                num = 0
                break
            else:
                num2 = random.uniform(0,1)
                if P_2 < num2 < 1:  #area corresponding to x_2
                    break  #loses
    print(wins/10**7)
The correct answer is 0.5821 however I am getting 0.655.. Where am I doing wrong ?
 
Last edited:
Technology news on Phys.org
Arman777 said:
**Problem:** Here’s a little Monte Carlo challenge problem, Consider the following game, which uses the two spinner disks. Suppose a player spins one or the other of the pointers on the disks according to the following rules: (1) if the player spins pointer i and it stops in the region with area pij, he moves from disk i to disk j (i and j are either 1 or 2); (2) if a pointer stops in the region with area xi, the game ends; (3) if the game ends in the region with area x1, the player wins, but if the pointer stops in the region with area x2 the player loses. What is the probability the player, starting with disk 1, wins? Assume the area of each disk is one, so that x1+p11+p12 =1, as well as that x2+p21+p22 =1

Run your code for the case of p11 =0.2, p12 =0.4, p21 =0.3, and p22 =0.35.
Mentor note: Changed ICODE tags to code=python
Python:
import random
    p_11 = 0.2
    p_12 = 0.4 #0.2+0.4
    p_21 = 0.3
    p_22 = 0.35    P_1 = p_11+p_12
    P_2 = p_21+p_22    #from starting 1:

    wins = 0
    num = 0
    for i in range(10**7):
        while num < P_1:
            num = random.uniform(0,1)
            if P_1 < num < 1:  #area corresponding to x_1
                wins += 1  #wins
                num = 0
                break
            else:
                num2 = random.uniform(0,1)
                if P_2 < num2 < 1:  #area corresponding to x_2
                    break  #loses
    print(wins/10**7)
The correct answer is 0.5821 however I am getting 0.655.. Where am I doing wrong ?
How do you know what the correct answer is? Also, it's a good idea to use random.seed() to seed the random number generator, but it doesn't seem to make much difference here.
 
I don't think your code captures what's supposed to happen here due to it being too simplistic. Based on your description, the pointer on the first disk can land on ##x_1## or ##p_{11}## or ##p_{12}##. If it lands on ##x_1##, that's a win for that turn. If it lands on ##p_{11}##, nothing happens for that spin. If it lands on##p_{12}##, you spin the pointer on the second disk.

If the second pointer lands on ##x_2##, that's a loss for that turn. If it lands on ##p_{22}## nothing happens, but if it lands on ##p_{21}##, the turn continues on the first disk.

I haven't seen how the game is defined, but I would bet it's something like I have described. If so, you need to take into account conditional probabilities, and all possible paths to a win for a given turn. The game makes me think of it as being a Markov process.
 
Last edited:
Mark44 said:
I don't think your code captures what's supposed to happen here due to it being too simplistic. Based on your description, the pointer on the first disk can land on ##x_1## or ##p_{11}## or ##p_{12}##. If it lands on ##x_1##, that's a win for that turn. If it lands on ##p_{11}##, nothing happens for that spin. If it lands on##p_{12}##, you spin the pointer on the second disk.

If the second pointer lands on ##x_2##, that's a loss for that turn. If it lands on ##p_{22}## nothing happens, but if it lands on ##p_{21}##, the turn continues on the first disk.

I haven't seen how the game is defined, but I would bet it's something like I have described. If so, you need to take into account conditional probabilities, and all possible paths to a win for a given turn. The game makes me think of it as being a Markov process.
Python:
import random
p_11 = 0.2
p_12 = 0.4 #0.2+0.4
p_21 = 0.3
p_22 = 0.35wins = 0
pointer = 0
pointer2 = 0
for i in range(10**6):
    while pointer < p_11:
        pointer2 = 0    #resetting pointer2
        pointer = random.uniform(0,1)
        if p_11+p_21  < pointer < 1:  #area corresponding to x_1
            wins += 1  #wins
            pointer = 0 
            break
        else:
            pointer = 0  #resetting pointer1
            lost = False
            while pointer2 < p_22:
                pointer2 = random.uniform(0,1)
                if p_22+p_21 < pointer2 < 1:  #area corresponding to x_2
                    pointer2 = 0
                    lost = True
                    break  #loses
            if lost:
                break

print(wins/10**6)

I noticed that there is an error in the book. The real answer is 0.65 and I edited my code like this which it works now. So problem is solved.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K