homework questions

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.

The homework requirements are as follows. You need to answer the following questions in the blog post. When answering a question, copy the question first, and then write the answer on a new line:

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: My first impression is that nothing has 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: After careful analysis, it is found that if you choose not to change the door, the probability should be the same as at the beginning, that is, the probability of choosing the car for the first time is 1/3; if you choose to change the door and still choose the car, then the first choice must be It is the sheep that is selected. In this case, the car will be selected after changing the door, that is, the probability of choosing a car after changing the door is equal to the probability of selecting a sheep for the first time. It is equal to 2/3. Therefore, the conclusion should be that the probability of choosing a car for changing doors is high.

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""
import random
n1=0
for i in range(10000):
    x1=random.randint(1,3)
    if  x1==1:
        n1 =n1+1
 print ( " The probability of selecting a car without switching is roughly {:.2f} " .format(n1/10000 ))
n2=0
for i in range(10000):
    x2=random.randint(1,3)
    if x2!=1:
        n2 =n2+1
 print ( " The probability of selecting a car is roughly {:.2f} " .format(n2/10000))

 

Guess you like

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