Goat Door Problem python simulation

Source: Internet
Author: User

Sheep door problem

Sheep Door Problem Description: There are 3 closed doors, one door behind the car, the other two doors are goats, the host knows what is behind each door. Contestants first choose a door. Before opening it, the host opens a door from another two doors, revealing the goat behind the door. At this point, participants are allowed to change their options. May I ask if the contestants can increase their chances of guessing the car after changing their options? By designing and Writing program validation, and giving your own explanations. The answer request is given in the following manner. (The sheep door has 3 closed door, a door parked car, another-door is a goat, the host knows every door. What's the first choice of the contestants in the open door. Before it, the moderator would open a door from the other of the doors, exposes the goat after. At this time, allow the participants change their choice. Choose the contestants after replacement, can increase the chance of guessing car?  Through design and program verification, and gives his own interpretation. )

1, I think will increase the opportunity to select the car.

The reasons are as follows:
(1) Do not change the choice: the probability of the choice of 1/3 (2) to choose: The probability of the choice before the replacement of the sheep, the replacement after the choice of the car. Probability is 2/3*1

2, program source code as follows):

From Random import*
Times = 10000
my_first_choice_n=0# initialization does not change the number of choices
my_change_choice_n=0# initialization changes the number of selections
For I in Range (times):
A= "Sheep 1", "Sheep 2", "Car"
Car_indoor=choice (a)
My_guess=choice (a)
If car_indoor==my_guess:
My_first_choice_n+=1
Else
My_change_choice_n+=1
Print ("Do not change selection: {}". Format (My_first_choice_n/times))
Print ("Change selection: {}". Format (My_change_choice_n/times))

3. The results of the validation run are as follows:

Goat Door Problem python simulation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.