Sheep 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: The first impression is that 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.

    A: It is more likely to change. The probability of selecting a car before the change is 1/3; the probability of selecting a car after the change: the probability of selecting a car again on the premise that the car was not selected for the first time is 2/3, which becomes larger.

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: Use a random function to randomly generate a number from 1 to 3, and then perform random generation for 10,000 times, count the number of the second generation that is the same or different from the first, and then divide by 10,000, that is, you can Calculate the probability that the non-replacement option is selected and the probability that the replacement option is selected, respectively.

   Verification results: The probability of getting a car without replacing is 0.33; the probability of getting a car by replacing it is 0.67. So my idea is verified.

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

 
import random
m=0
n=0
for i in range(0,10000):
    a = random.randint (1,3 )
    b=random.randint(1,3)
    if a==b:
        m=m+1
    else:
        n =n+1
 print ( " The probability of getting a car without changing the choice is {:.2f} " .format(m/10000 ))
 print ( " The probability of getting a car by changing the choice is {:.2f} " .format(n /10000))

 

Guess you like

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