Sheep door problem (pair work)

Job done by:

Student ID: 20171301095, Xiao Tong

Student ID: 20171301099, Song Miao

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 of getting a car 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: Ideas:

              (1) Don't change the choice: the probability of choosing a car for the first time is 1/3, and the probability of choosing a sheep is 2/3, so the probability of getting a car without changing the choice = 1/3.

              (2) Replacement selection: The chance of choosing a car for the first time is 1/3, and the chance of getting a car after changing the selection is 0.

                                         The chance of picking a sheep for the first time is 2/3, and the chance of getting a car after changing choices is 1.

                                         To sum up, the probability of getting a car after changing the choice = 1/3*0+2/3*1=2/3.

       result:

                Replacement options give a higher chance of getting a car.

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 program running result:

                              The probability of getting the car without the replacement option is: 0.3330739850049512 The probability of
                              getting the car with the replacement option is: 0.6669260149950488

       The program run results support my analysis.

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

import random
x = random.randint (10000,100000)
m=0
n=0
for i in range(1,x+1):
    p = random.randrange (1,4)
    q = random.randrange (1,4)
    if p==q:
        m=m+1
    else:
        n=n+1
print("The probability of getting a car without changing the choice is: {}".format(m/x))
print("The probability of getting a car by changing the selection is: {}".format(n/x))

 

Guess you like

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