Homework: Sheep Car Door Problem

Job done by:

Student ID: 20071301026, Wang Xue

Student ID: 20171301020, Ma Luyao

Title description: There are 3 closed doors, behind one door is parked cars, behind the rest are goats, only the host knows what is behind each door. Contestants can choose a door, and before opening it, the host will open another door, revealing the goat behind the door, and then allow the contestant to change their choice.

Question 1 :

I don't think the odds have changed.

Question 2 :

We assume that the relationship between the three doors and the car and sheep are:

The first door: sheep The second door: the car The third door: the sheep

① If not replaced:

The probability of the contestant getting the car is 1/3

② If you change it:

The probability of a contestant getting a car is 2/3. When a contestant chooses a door, before opening it, the host will open a door with a sheep hidden behind it. When a contestant chooses the first door or the third door, if they change it, they will definitely switch to the second door. car; if the car with the second door is selected, then the replacement will definitely be the sheep with the first door or the third door.

In summary, the probability of switching to a car is 2/3.

Question 3 :

 confirmed the conjecture.

The number of tests is: 100000
If you don't change it, the probability of getting the car is 0.33097.
If you change it, the probability of getting the car is 0.66903.
>>>

Question 4 :

 

import random
TIMES=eval(input("The number of tests is: "))
a=0
for i in range (TIMES):
    m = random.randint (0,2)
    if m==0 :
       a=a+1
print("If you don't change, the probability of getting the car is {}.".format(a/TIMES))
print("If you change, the probability of getting a car is {}.".format(TIMES-a)/TIMES)

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325118152&siteId=291194637