五千年(敝帚自珍)

主题:【文摘】一道有趣的概率题 -- 天下第一银杏树

共:💬28 🌺15
分页树展主题 · 全看首页 上页
/ 2
下页 末页
        • 家园 不同意你,也不同意冷眼旁观

          凡是给出了确定解的,统统不同意

          首先,这题是经典概率题,并且事件空间可以手工枚举,所以Monte Carlo没有用。就算Monte Carlo,你仍然面临着样本是怎么抽的问题。对应在经典概率里,就是等概率事件是怎么定义的。这个问题绕不开。

          这道题为什么会这么tricky?就在于题作者故意把牵涉到等概率假设的关键地方模棱两可的说出来,并且不让你察觉。在这个问题上,可以有不同的假设,并导致不同的答案。自己心里设定了自己的假设,就怎么也不会理解别人的答案。

          好,仔细看这句话

          然后主持人打开了一扇门,让你看清楚这扇门背后是只羊

          至少有两种理解。

          一,主持人知道哪扇门背后有车,但故意不开那扇门,而开了一扇有羊的门。这是衲子的假设。

          二,主持人也不知道哪扇门背后有车,或者知道而闭着眼睛随便开了一扇。然后出现了“后验”的结果,就是被打开的这扇门后面刚好是羊。这是很多其他人的假设。

          • 家园 disagree again

            My only assumption is that the door you picked at your first try is random. It doesn't matter how the hostess picked her door (as long as it revealed a goat). Even in the second case of your understanding, my derivation would still hold.

            Some webpages have discussed this problem, and have mentioned that if the hostess had chosen her door randomly, which happened to reveal a goat, then switching door wouldn't enhance your chance of getting the car. I suspect you might have been influenced by those webpages, and I don't think that idea is correct.

            In my Monte Carlo simulation, actually the hostess also chose the door randomly, but the events in which the door revealed a car were thrown away, as they violate the constraint that the door has to reveal a goat.

            Intuitively, we can understand this problem as follows. Let event Ai = {you picked door #i}, and event Gj = {door #j, j!=i, reveals a goat}. We can verify Ai and Gj are not independent, i.e., they contain nonzero mutual information. So it's understandable that given this new piece of information Gj, your strategy can improve.

            Anyhow, if my previous analysis doesn't convince you, you're welcome to write a small program to verify it--your case 2 specifically.

            • 家园 I actually did manually list all cases. May I see your code pls?
              • 家园 my annotated MATLAB code. How about ur manual list?

                N = 1e3; % total # of runs

                % behind door # 1 is the car. This configuration is fixed, while your draws are random.

                Upick = ceil(3*rand(N,1)); % the door you picked in each of N runs.

                P_no_swtch = length(find(Upick==1))/N; % probability of getting the car if you don't switch

                SWTCH = [0, 3, 2;

                3, 0, 1;

                2, 1, 0]; % SWTCH(a,b) denotes the target door as you switch, when you have

                % picked door #a, and the host has showed door #b.

                P_swtch = 0; % Initialize: probability of getting the car if you do switch

                for k = 1:N

                host = ceil(3*rand(1)); % the host randomly picks a door, #1->#3

                while host == Upick(k) || host ==1 % this door has to be different

                host = ceil(3*rand(1)); % from your door, and it has to reveal a goat.

                end

                NewChoice= SWTCH(Upick(k), host);

                if NewChoice == 1 % is a car

                P_swtch = P_swtch + 1; % accumulate the hits

                end

                end

                P_swtch = P_swtch/N;

                %% Conclusion:

                [P_no_swtch, P_swtch]

                % == [0.3320, 0.6680], i.e., [1/3, 2/3]. Therefore switching is preferable.


                本帖一共被 1 帖 引用 (帖内工具实现)
                • 家园 清楚了

                  你实现的不是我的假设二,而是假设一。请看这句:

                  while host == Upick(k) || host ==1 % this door has to be different

                  host = ceil(3*rand(1)); % from your door, and it has to reveal a goat.

                  end

                  出了循环之后,主持人永远只会选出羊,这不正是假设一么?

                  假设二要求的是,主持人有可能在某些run中选到车,但这些情况不符合后验要求,所以在统计概率时剔除。我们要计算的是 P(游戏者换个门里面是羊|主持人开的门里面是羊),括号里|后面的这半段,就是下面successful_runs统计的符合后验的情况数。下面是我改过之后的程序。运行结果显示在这种假设下是1/2对1/2的概率。你的程序显示了另一种情况。所以两种都有可能。

                  N = 1e3; % total # of runs

                  % behind door # 1 is the car. This configuration is fixed, while your draws are random.

                  Upick = ceil(3*rand(N,1)); % the door you picked in each of N runs.

                  %P_no_swtch = length(find(Upick==1))/N; % probability of getting the car if you don't switch

                  SWTCH = [0, 3, 2;

                  3, 0, 1;

                  2, 1, 0]; % SWTCH(a,b) denotes the target door as you switch, when you have

                  % picked door #a, and the host has showed door #b.

                  P_swtch = 0; % Initialize: probability of getting the car if you do switch

                  successful_runs = 0;

                  for k = 1:N

                  host = ceil(3*rand(1)); % the host randomly picks a door, #1->#3

                  while host == Upick(k) % this door has to be different

                  host = ceil(3*rand(1)); % from your door.

                  end

                  if host ~= 1 % only count the cases when the host doesnot choose the car.

                  successful_runs = successful_runs + 1;

                  NewChoice= SWTCH(Upick(k), host);

                  if NewChoice == 1 % is a car

                  P_swtch = P_swtch + 1; % accumulate the hits

                  end

                  end

                  end

                  P_swtch = P_swtch/successful_runs;

                  P_no_swtch = length(find(Upick==1))/successful_runs;

                  %% Conclusion:

                  [P_no_swtch, P_swtch]

                  % == [0.4938 0.5062], i.e., [1/2, 1/2]. Therefore switching doesnot help underthis assumption.

                  • 家园 I see. It all boils down to the question what is Omega?

                    This can be better understood by drawing a Venn diagram.

                    In your interpretation, the case might as well be presented as follows: The hostess first pick a door randomly, which happens to reveal a goat. Conditioned on this, would you have any preference as to which of the remaining two doors to pick? Of course not, since each door would have the probability of 1/2 of hiding a car!

    • 家园 应重新选择, 概率变大 1/3 -> 2/3, Monte Carlo verified

      i. 不重新选:

      猜对汽车概率 1/3

      ii. 重新选:

      1/3概率: originally you have picked the car, after switching, you loose the car.

      2/3概率: originally you have picked the goat, after switching, you gain the car.

      -----------

      Conclusion: you SHOULD switch!

      You can write a simple Monte Carlo program to verify it.

    • 家园 概率变大了(1/3-》1/2),但事件仍然是等概率的,信息量为0。

      所以重新选择没有意义。

      • 家园 没这么简单,这道题很有意思的。

        这道题其实条件没有给清楚,所以要看假设,假设不同,答案就不同。电子狼已经给出了一点暗示。然后仔细看这句话:“然后主持人打开了一扇门,让你看清楚这扇门背后是只羊”。主持人究竟是按什么规则来开的门,这里面问题可大了。可不可以开被选中的门?可不可以开汽车之门?

    • 家园 这个问题我见过,在91年的少年科学杂志上有。

      推导过程不记得了,但结果记得――下次选出汽车的概率没有增加。

    • 家园 我的问题和回答

       关键是,主持人打开的是你选中的1号们吗?如果一定不是,那么我的回答:

       重新选择不会增加猜对的概率。

       汽车在一号门的概率是从开门前的1/3增加到1/2,但猜错的概率也提高到1/2,所以重新选择对“猜对汽车”没有帮助。

       

分页树展主题 · 全看首页 上页
/ 2
下页 末页


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河