"The Sheep Door Problem"

Assignee :
Student ID: 20171301053 Jia Xinhui

Student ID: 20171301043 Shi Bingsen

1. Answer according to your first feeling, do you think there is 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?

Jia: You have a higher chance of getting a car if you don’t change your choice.

Stone: Switching options can have a higher chance of getting a car.

2. Please carefully analyze by yourself, "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.

After mathematical analysis: first decompose the problem into two cases of exchange and no exchange, and then find the probability and judge respectively. (1) Don't change the choice: After selecting the car, the probability of selecting the car is 1/3, and if you do not change the choice, the final probability is 1/3. (2) Change the choice: If you want to choose a car, you must select the sheep for the first time. , that is, 2/3, the second time the host opens a door, the car will be selected by changing the choice, that is, the probability is 1, then 2/3*1=2/3, then the final probability is 2/3.

So we all agree that we should change our options.

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.

After multiple verifications by programming, the results support our analysis results, and the results are as follows:

Do not change the choice 0.3251
Change the choice 0.6749

Do not change the choice 0.3281
Change the choice 0.6719

Do not change the choice 0.331
Change the choice 0.669

4. Please attach your code.

import random
TIMES = 10000
n1 = 0
n2 = 0
for i in range (TIMES):
    a=random.randint(0,2)
    if a==0:
        n1=n1+1
    else:
        n2 =n2+1
 print ( " Don't change selection{} " .format(n1/ TIMES))
 print ( " Change selection{} " .format(n2/TIMES))

 

Guess you like

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