关于直觉

本文通过模拟实验探讨了一个经典概率问题:在游戏节目中,参与者在三个箱子中选择一个,其中一个装有奖品,其余为空。主持人会揭示一个空箱后询问参与者是否更换选择。通过编程模拟10万次实验发现,更换选择获奖概率为2/3,坚持原选择的概率为1/3。
今天又见到这个智力问题了:

假设你参加了一个游戏节目,现在要从三个密封的箱子中选择一个。其中两个箱子是空的,另一个箱子里面有大奖(你偶像的签名^^)。你并不知道奖在哪一个箱 子里,但主持人知道。游戏节目的主持人先要你选择一个箱子,接着他把你没有选的空箱子打开,以证明它是空的。最后主持人给你换箱子的机会,你可以把你所选 择的箱子换成另一个没有打开的箱子。此时你该不该换箱子?

我的直觉告诉我,换与不换概率都是1/2.因为没有选择的那两个箱子里必定至少有一个是空的,这是个确定事件,所以,无论是否把它纠出来,对我的选择的 正确率都是没有影响的.而主持人指出那个空箱子的过程,那个箱子是正确的概率就应该平均分布到剩下的两个箱子中去了--概率他老人家应该是公平的吧,大概 不会偏向某一个箱子吧:)

回答这个问题的大致分为两派,一派选换,一派选不换(废话嘛,就俩答案...),我对自己的答案颇有信心,但在说服不同意见者方面没有多少信心--大家也知道,网上争吵一般是不会出现什么结果的,于是就写了段代码,让程序说话:

ContractedBlock.gifExpandedBlockStart.gifProgram.cs
None.gifusing System;
None.gif
None.gif
namespace SureNoChange
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
class Program
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
static void Main(string[] args)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int timesToTry = 100000;
InBlock.gif
InBlock.gif            
int winsWithChange = SimulateChange(timesToTry);
InBlock.gif            Console.WriteLine(
"Wins after change decision: {0}/{1}", winsWithChange, timesToTry);
InBlock.gif
InBlock.gif            
int winsWithOutChange = SimulateNoChange(timesToTry);
InBlock.gif            Console.WriteLine(
"Wins without change decision: {0}/{1}", winsWithOutChange, timesToTry);
InBlock.gif
InBlock.gif            Console.ReadKey();
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private static int SimulateChange(int timesToTry)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int timesWin = 0;
InBlock.gif            
for (int i = 0; i < timesToTry; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Game game 
= new Game();
InBlock.gif                game.PlayerSelectAnOption();
InBlock.gif                game.RemoveOneWrongOption();
InBlock.gif                game.ChangeChoice();
InBlock.gif
InBlock.gif                
if (game.Win)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    timesWin
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
return timesWin;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private static int SimulateNoChange(int timesToTry)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
int timesWin = 0;
InBlock.gif
InBlock.gif            
for (int i = 0; i < timesToTry; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                Game game 
= new Game();
InBlock.gif                game.PlayerSelectAnOption();
InBlock.gif                game.RemoveOneWrongOption();
InBlock.gif                
if (game.Win)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    timesWin
++;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
return timesWin;
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
ContractedBlock.gifExpandedBlockStart.gifGame.cs
None.gifusing System;
None.gif
using System.Collections.Generic;
None.gif
None.gif
namespace SureNoChange
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
class Game
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        Random r;
InBlock.gif        Choice prize;
InBlock.gif        Choice choice;
InBlock.gif        Choice open;
InBlock.gif
InBlock.gif        
public Game()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            r 
= new Random();
InBlock.gif            prize 
= GetRandomChoice();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 玩家随机选择一个箱子
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        internal void PlayerSelectAnOption()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            choice 
= GetRandomChoice();
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 从未被选择的,不是答案的箱子里打开一个
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        internal void RemoveOneWrongOption()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            List
<Choice> openable = new List<Choice>();
InBlock.gif            openable.AddRange(AllChoices);
InBlock.gif
InBlock.gif            openable.Remove(choice);
InBlock.gif            openable.Remove(prize);
InBlock.gif
InBlock.gif            open 
= openable[r.Next(openable.Count)];
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
private Choice GetRandomChoice()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
return AllChoices[r.Next(3)];
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 从先前选择的,打开的箱子以外的所有箱子里再随机选择一个
ExpandedSubBlockEnd.gif        
/// </summary>

InBlock.gif        internal void ChangeChoice()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            List
<Choice> rest = new List<Choice>();
InBlock.gif            rest.AddRange(AllChoices);
InBlock.gif
InBlock.gif            rest.Remove(open);
InBlock.gif            rest.Remove(choice);
InBlock.gif
InBlock.gif            Choice newChoice 
= rest[r.Next(rest.Count)];
InBlock.gif            choice 
= newChoice;
ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
internal bool Win
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
return choice == prize;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif
InBlock.gif        
static List<Choice> allChoices;
InBlock.gif        
static List<Choice> AllChoices
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (allChoices == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    allChoices 
= new List<Choice>();
InBlock.gif                    allChoices.AddRange((Choice[])Enum.GetValues(
typeof(Choice)));
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return allChoices;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
ContractedBlock.gifExpandedBlockStart.gifChoice.cs
None.gifnamespace SureNoChange
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
enum Choice
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        A,
InBlock.gif        B,
InBlock.gif        C,
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif


但是,结果却是:

Wins after change decision: 66924/100000
Wins without change decision: 
35009/100000

晕了,我的直觉居然错了!更改选择的话,得到奖品的可能性是2/3,不改的话,是1/3!

如果对这个宏观的"概率坍缩"的直觉都能犯这么大的错误,那些搞量子物理的,一再被实验结果打击,岂不会疯掉...

转载于:https://www.cnblogs.com/deerchao/archive/2008/02/05/1065147.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值