Goat door Problem

Source: Internet
Author: User

Goat door Problem

1. I thinkYesIncrease the chance of selecting a car

The reason is as follows:

There are a total of N doors, and there is a car behind one of them.

In the first case, I select a door. After the host prompts me, I will not change the selection.
So what I decided to win was event A, "I selected A door with A car at A time", which had nothing to do with the subsequent events.
Event probability/winning probability:

Case 2: I select a door and change the selection after the host prompts.
So, I decided to win two events:

Event B "I chose a car-less door for the first time ";

Event C "in case of Event B, I chose a car door for the remaining optional doors ." (At this time, except for the first selection of the door and the host opened the door, the remaining optional door only N-2 fan)

Event Probability :;;

Winning probability:

Compared with the above situations, we can see that:

When N = 3, the probability of selection is 0.333. If N = 3, the probability of selection is 0.667.

That is, the change option will increase the chance of selection.

2. The program source code is as follows:

From random import * a = ('chely', 'yang', 'yang') # construct the post-door condition sequence B = ('change', 'change ') # construct two selection sequence T = 1 # initial number of experiments: 1 uncWIN = 0 # event A does not change the number of selected vehicles chaWIN = 0 # event C changes the number of selected vehicles unchange = 0 # 'do not change' occurrence times change = 0 # 'change 'occurrence times while T <100000: # assume that the number of tests is 100000 if choice (B) = 'do not change': # select do not change = unchange + 1 if choice (a) = 'chely ': uncWIN = uncWIN + 1 else: # select change = change + 1 if choice (a) = 'yang ': chaWIN = chaWIN + 1 T = T + 1 Punwin = uncWIN/unchangePchwin = chaWIN/changeprint ("tested {} Times ". format (T) print ("the probability of not selecting a car is :{}". format (Punwin) print ("the probability of selecting a car after changing is :{}". format (Pchwin) if Punwin> Pchwin: print ("the probability of not switching to a car is high") else: print ("the probability of selecting a car after switching is high ")

3. The verification result is as follows:

 

 

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.