Solve the sheep door problem

homework finisher

Fu Yana 20171301049

Liu Yanbing 20171301061

1. Answer according to your first feeling. Do you think you have a higher chance of getting a car if you don’t change the choice, or do you think you can get a car with a choice? Or the odds haven't changed?

 

A: The odds have not changed.

 

2. Please carefully analyze "Is there a higher chance of getting a car if I don't change the choice, or is there a higher chance of getting a car if I change the choice? Or the probability has not changed?" Write down your analysis ideas and results.

 

Answer: The probability of choosing a car at the beginning is 1/3. After removing a door with a sheep behind it, no matter what is behind the door selected at the beginning, there is a 1/2 probability of choosing a car. It doesn't matter if you change it or not.

 

3. Please try to write a program to verify your ideas. The verification results support your analysis results, or do not support your analysis results. Please write the program running results and whether they support your analysis. (Hint: This procedure can be done with the help of the random number function)

 

Answer: The probability of getting a car without changing it is 0.33258.

The probability of getting a car instead is 0.66742. Our analysis is not supported.

 

4. Please attach your code. (Hint: Use the Insert Code feature in the editor to display the code in Python style)

 

code show as below:

import random

Y=0

N=0

TIMES=100000

for i in range(TIMES):

    m=random.choice(range(3))

    if m==0:

        N=N+1

    else:

        Y=Y+1

print("The probability of getting a car without changing is {}.".format(N/TIMES))

print("The probability of getting a car is {}.".format(Y/TIMES))

Guess you like

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