主题:【文摘】一道有趣的概率题 -- 天下第一银杏树
你实现的不是我的假设二,而是假设一。请看这句:
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.
- 相关回复 上下关系8
disagree again 2 衲子 字1267 2005-08-05 20:46:30
I actually did manually list all cases. May I see your code pls? 林小筑 字0 2005-08-05 21:49:45
my annotated MATLAB code. How about ur manual list? 1 衲子 字1144 2005-08-05 23:17:31
清楚了
I see. It all boils down to the question what is Omega? 衲子 字388 2005-08-06 01:16:06
应重新选择, 概率变大 1/3 -> 2/3, Monte Carlo verified 1 衲子 字321 2005-08-05 14:58:49
😜del landlord 字0 2005-08-05 15:17:59
概率变大了(1/3-》1/2),但事件仍然是等概率的,信息量为0。 1 寓幻 字22 2005-08-05 12:16:06