Search
Clear search
Close search
Main menu
Google apps
Groups
Sign in
Groups
人工社会
Conversations
About
Send feedback
Help
080108统计模拟法计算pai的近似值.xls
7 views
Skip to first unread message
forcode(奇想录)
unread,
Jan 7, 2008, 4:25:38 PM
1/7/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to as
前天在广州图书馆看ross的《统计模拟》里的一个例题,今天按照回忆在excel里弄出来了计算pai值的办法,可见模拟法还是挺有用的。
原理很简单:
一个边长为2的正方形,面积也就是4,中间有一个半径为1的圆,按照公式,圆的面积是pai,那么,模拟正方形内N个均匀分布的随机点,如果落在圆内就编码为1,如果落在圆外的正方形内,就编码为0,然后所有编码值加起来除以N,就是圆的面积占正方形的面积的近似比例,也等于pai/4,这样,N越大,算出来的pai值越精确,我模拟了1000个点, 刚好算出来pai值等于3.14,因为我将这1000个随机点距离圆心的距离排序之后,第785个值开始大于1,意味着786之后的点都落在圆外,785×4/1000=3.14。如果模拟更多的点,就可以得到更加精确的pai值。
附件里是excel表格,有兴趣可以看看。
我今天从图书馆借了《复杂系统建模与仿真》这本书,寒假好好看看。
080108统计模拟法计算pai的近似值.xls
曹政
unread,
Jan 7, 2008, 4:37:40 PM
1/7/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to artifici...@googlegroups.com
吴兄,信都已收到,非常感谢!关于excel的分析,看到了3.14,却不知是如何每一个点的概率的,请指教,谢谢!
在08-1-8,
forcode(奇想录)
<
wood...@gmail.com
> 写道:
forcode(奇想录)
unread,
Jan 7, 2008, 4:46:14 PM
1/7/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to artifici...@googlegroups.com
你看我每列的公式就知道了。
A这列用:=rand()生成了1000个0~1之间的随机数
B这格用:=2*$a1生成了1000个0~2之间的随机数
C这格用:=$b1-1生成了1000个-1~+1之间的随机数,用于模拟随机点的X坐标
D格同C类似,用于模拟随机点的Y坐标
然后E格用X、Y坐标来计算该点距离圆心的距离。
然后F格排序,计算距离圆心小于1的点(也就是落在圆内的点)的数量,也就是圆的面积与正方形面积的近似比例。
曹政
unread,
Jan 7, 2008, 4:51:24 PM
1/7/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to artifici...@googlegroups.com
这些都看到了,就是rand(),2*$a1,$b1-1不太清楚是什么意思,呵呵
Hu, Jiangtang
unread,
Jan 8, 2008, 2:58:00 AM
1/8/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to artifici...@googlegroups.com
这就是传说中的蒙特卡罗模拟了。
--
胡江堂
北京大学软件与微电子学院06硕
生活博客(读书、见闻):
http://panshanghu.spaces.live.com/
技术博客(数据挖掘、金融计算、SAS、etc.):
http://johnthu.spaces.live.com/
Reply all
Reply to author
Forward
0 new messages