定义
在数学与统计学中,大数定律又称大数法则、大数律,是描述相当多次数重复实验的结果的定律。根据这个定律知道,样本数量越多,则其算术平均值就越趋近期望值。
举例
1)抛掷一颗均匀的6面的骰子,六面出现概率为
数据 |
1 |
2 |
3 |
4 |
5 |
6 |
概率 |
1/6 |
1/6 |
1/6 |
1/6 |
1/6 |
1/6 |
数学期望 = 1 × (1/6) + 2 × (1/6) + 3 × (1/6) + 4 × (1/6) + 5 × (1/6) + 6 × (1/6)
数学期望 = 3.5
2)使用程序模拟投掷过程
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| public class Application { public static void main(String[] args) { int count = 100 * 10000; int oneCount = 0; int twoCount = 0; int threeCount = 0; int fourCount = 0; int fiveCount = 0; int sixCount = 0; for (int i = 1; i <= count; i++) { int ran = (int) (Math.random() * 6) + 1; switch (ran) { case 1: oneCount = oneCount + 1; break; case 2: twoCount = twoCount + 1; break; case 3: threeCount = threeCount + 1; break; case 4: fourCount = fourCount + 1; break; case 5: fiveCount = fiveCount + 1; break; case 6: sixCount = sixCount + 1; break; } if (i == 100 || i == 10000 || i == 1000000) { System.out.println("第" + i + "次统计:"); System.out.println("1\t2\t3\t4\t5\t6"); System.out.print(oneCount + "\t"); System.out.print(twoCount + "\t"); System.out.print(threeCount + "\t"); System.out.print(fourCount + "\t"); System.out.print(fiveCount + "\t"); System.out.println(sixCount); System.out.print(new BigDecimal(oneCount).divide(new BigDecimal(i)) + "\t"); System.out.print(new BigDecimal(twoCount).divide(new BigDecimal(i)) + "\t"); System.out.print(new BigDecimal(threeCount).divide(new BigDecimal(i)) + "\t"); System.out.print(new BigDecimal(fourCount).divide(new BigDecimal(i)) + "\t"); System.out.print(new BigDecimal(fiveCount).divide(new BigDecimal(i)) + "\t"); System.out.println(new BigDecimal(sixCount).divide(new BigDecimal(i))); } } } }
|
3)统计结果
第100次统计:
数据 |
1 |
2 |
3 |
4 |
5 |
6 |
出现次数 |
17 |
15 |
16 |
19 |
21 |
12 |
出现概率 |
0.17 |
0.15 |
0.16 |
0.19 |
0.21 |
0.12 |
总数为:348
算术平均数为:3.48
第10000次统计:
数据 |
1 |
2 |
3 |
4 |
5 |
6 |
出现次数 |
1724 |
1638 |
1639 |
1636 |
1664 |
1699 |
出现概率 |
0.1724 |
0.1638 |
0.1639 |
0.1636 |
0.1664 |
0.1699 |
总数为:34975
算术平均数为:3.4975
第1000000次统计:
数据 |
1 |
2 |
3 |
4 |
5 |
6 |
出现次数 |
167149 |
166751 |
166553 |
166521 |
166688 |
166338 |
出现概率 |
0.167149 |
0.166751 |
0.166553 |
0.166521 |
0.166688 |
0.166338 |
总数为:3497862
算术平均数为:3.497862
结论
随着投掷次数的不断增多,算术平均数无限接近于期望值