car door work

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: According to my first impression, I think switching options will have a higher chance of getting a car.

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: If you don't change your choice, there are three doors in total, only one door has a car, and there is only one chance to choose. Theoretically, the probability of choosing a car is 1/3. Let's look at the choice again. There are only two choices for a contestant. One is sheep and the other is car. When the host opens a sheep's door, if the sheep was originally selected, the car is now selected. If the original choice was a car, the changed choice is now a car, so the probability of choosing a car in the end is theoretically equal to the probability of choosing a sheep for the first time. Before the first choice, the host did not open a door for the sheep, so the probability of picking the sheep for the first time is 2/3.

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 result of the program running is: The following is the result of the program running and analysis.
Calculate the probability of this event. The number of times you want to experiment is:

The probability of not changing the choice to draw a car is 0.334       

After performing n experiments, the probability of picking a car is 0.694

import   random
 print ( " The following is the result of the program running and analyzing " )
n =int(input( " Calculate the probability of this event The number of times you want to experiment is: " ))
s=0
z=0
for  i in  range (1000):
    b=random.randint(1,3)
    if b==2:
        s=s+1
for  i  in  range  (1000):
    b=random.randint(1,3)
    if  b==2:
        c=1
    if  b==1 or  b==3:
         c=2
    if  c==2:
         z =z+1         
 print ( " After performing {} experiments, the probability of drawing a car without changing is {} " .format(n,s/ n))
 print ( " After performing {} experiments, drawing when changing The probability of arriving at the car is {} " .format(n,z/n))

 

Guess you like

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