Sheep door problem Sheep door problem

sheep door problem

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 have a higher chance of getting a car if you change the choice? Or the odds haven't changed?

A: My first impression is that switching options has 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.

Answer: Analysis idea: set the two sheep as AB and the car as C. If you change it: one is to choose C at the beginning, and the host drives A or B; the other is to choose A, the host to drive B, and the third is to choose B, the host to drive A, so the probability It is 2/3, if not, it is 1/3.

  Result: Switching options has 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.

A: The validation results support my analysis.

       Running result: Change the choice to get the car probability: 0.66667

                         Chance of getting a car without changing the choice: 0.3333

4. Please attach your code.

code show as below:

import random
s=random.randint(5000,10000)
nochange = 0
change = 0
for i in range(1,s+1):
    yang = random.randint (1,3 )
    che = random.randint (1,3 )
     if yang == che:
        nochange=nochange+1
    else:
        change =change+1
         print ( " Do not change selected: {} " .format(nochange/ s))
         print ( " Change selected: {} " .format(change/s))

 

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 have a higher chance of getting a car if you change the choice? Or the odds haven't changed?

A: My first impression is that switching options has 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.

Answer: Analysis idea: set the two sheep as AB and the car as C. If you change it: one is to choose C at the beginning, and the host drives A or B; the other is to choose A, the host to drive B, and the third is to choose B, the host to drive A, so the probability It is 2/3, if not, it is 1/3.

  Result: Switching options has 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.

A: The validation results support my analysis.

       Running result: Change the choice to get the car probability: 0.66667

                         Chance of getting a car without changing the choice: 0.3333

4. Please attach your code.

code show as below:

import random
s=random.randint(5000,10000)
nochange = 0
change = 0
for i in range(1,s+1):
    yang = random.randint (1,3 )
    che = random.randint (1,3 )
     if yang == che:
        nochange=nochange+1
    else:
        change =change+1
         print ( " Do not change selected: {} " .format(nochange/ s))
         print ( " Change selected: {} " .format(change/s))

 

Guess you like

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