高尔顿钉板试验模拟(程序)

更新时间:2023-05-10 02:34:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

高尔顿钉板试验模拟(程序)

高尔顿钉板试验模拟(程序)

...这是我2005年12的课程设计中程序的核心部分,写完后自己非常得意,等着老师表扬。等啊等,等待现在也没等到 :em16:

现将它献给大家...(若有版权那遵守BSD吧) 注1:程序以前是用Matlab写的现用Java重写

注2:原程序中 galton返回值为 int[] grid 、没有“输出结果”部分

public void galton(int sumOfGrid, int sumOfBall){ int[] grid = new int[sumOfGrid];

int number = 0; //一个小球从顶端落下过程中向右偏移的总次数

int rand ; //随机数,取值范围为{0,1},为0、为1的概率相等

for( int counter_ball = 1; counter_ball <= sumOfBall; counter_ball++ ){ //<核心>

// (sumOfGrid - 1)为钉板的层数

for( int times = 1; times <= ( sumOfGrid - 1 ); times++ ){ rand = (int)( Math.random()*2 ); number += rand; }

grid[number]++; number = 0; //</核心> }

//输出结果

System.out.println( "小球的总数为"+sumOfBall+"\t格子的个数为"+sumOfGrid );

for( int index = 0; index < grid.length; index++ )

System.out.println( (index+1)+"号格子中的小球数为:\t"+grid[index] ); }

}//end of metod galton

高尔顿钉板试验模拟(程序)

补充:(谢谢2楼提醒 :-D )

高尔顿钉板试验:自板上端放入一小球, 任其自由落下.在下落过程中, 当小球碰到钉子时, 从左边落下与从右边落下的机会相等.碰到下一排钉子也是如此.自板上端放入n(n自行输入)个小球, 观察小球落下后呈现曲线并统计小球落入各个格子的频率.

高尔顿钉板试验可见《概率论》(复旦大学 李贤平)

当小球数量少时分布无明显特征,当小球数量多时(>100)分布近似正态分布。(即两边对称:-D) 当时为了证明服从正态分布投1千万个小球(计算机模拟 :-D)

高尔顿钉板试验模拟(程序)

Galton Board

The Galton board, also known as a quincunx or bean machine, is a device for statistical experiments named after English scientist Sir Francis Galton. It consists of an upright board with evenly spaced nails (or pegs) driven into its upper half, where the nails are arranged in staggered order, and a lower half divided into a number of evenly-spaced rectangular slots. The front of the device is covered with a glass cover to allow viewing of both nails and slots. In the middle of the upper edge, there is a funnel into which balls can be poured, where the diameter of the balls must be much smaller than the distance between the nails. The funnel is located precisely above the central nail of the second row so that each ball, if perfectly centered, would fall vertically and directly onto the uppermost point of this nail's surface (Kozlov and Mitrofanova 2002). The figure above shows a variant of the board in which only the nails that can potentially be hit by a ball dropped from the funnel are included, leading to a triangular array instead of a rectangular one.

Each time a ball hits one of the nails, it can bounce right (or left) with some probability p(and q 1 p). For symmetrically placed nails, balls will bounce left or right with equal probability, so p q 1/2. If the rows are numbered from 0 to N 1, he path of each falling ball is a Bernoulli trial consisting ofNsteps. Each ball crosses the bottom row hitting the nth peg from the left (where0 n N 1) if it has taken exactly right turns, which occurs with probability

This process therefore gives rise to a binomial distribution of in the heights of heaps of balls in the lower slots.

If the number of balls is sufficiently large and, then according to the weak law of large numbers, the distribution of the heights of the ball heaps will approximate a normal distribution.

Some care is needed to obtain these idealized results, however, as the actual distribution of balls depends on physical properties of the setup, including the elasticity of the balls (as characterized by their coefficient of restitution), the radius of the nails, and the offsets of the balls over the funnel's opening when they are dropped (Kozlov and Mitrofanova 2002).

高尔顿钉板试验模拟(程序)

z

数理统计

y

x

--------------------------------------------------------------------------------------------------------------------------------Reproduction Forbidden Page 4 of 8

高尔顿钉板试验模拟(程序)

z

数理统计

y

x

--------------------------------------------------------------------------------------------------------------------------------Reproduction Forbidden Page 5 of 8

高尔顿钉板试验模拟(程序)

z

数理统计

y

x

--------------------------------------------------------------------------------------------------------------------------------Reproduction Forbidden Page 6 of 8

高尔顿钉板试验模拟(程序)

z

数理统计

y

x

--------------------------------------------------------------------------------------------------------------------------------Reproduction Forbidden Page 7 of 8

高尔顿钉板试验模拟(程序)

z

数理统计

y

x

--------------------------------------------------------------------------------------------------------------------------------Reproduction Forbidden Page 8 of 8

本文来源:https://www.bwwdw.com/article/r2xe.html

Top