In probability theory , Law of large Numbers (LLN) A theorem describing the results of a large number of identical experiments . According to the law , The average value of the results obtained from a large number of tests shall be close to the expected value , And with the increase of test times, it tends to be close to the expected value .
LLN Very important , Because it guarantees the long-term stable result of the average value of some random events . for example , Although casinos may lose money in a single spin of roulette , But its returns will tend to be predictable percentages in a large number of rotations . Any winning streak of players will eventually be overcome by the parameters of the game . It should be noted that , The law only applies when a large number of observations are considered ( As shown in the name ). There is no principle that a few observations will be consistent with the expected values , Or the continuity of one value is immediately changed by other values “ Balance ”.
In addition, we should pay attention to ,LLN For average values only . therefore , although
lim n → ∞ ∑ i = 1 n X i n = X ˉ \lim _{n \rightarrow \infty} \sum_{i=1}^{n} \frac{X_{i}}{n}=\bar{X} n→∞limi=1∑nnXi=Xˉ
Other unproven formulas that look similar , For example, “ Theoretical results ” Original deviation of :
∑ i = 1 n X i − n × X ˉ \sum_{i=1}^{n} X_{i}-n \times \bar{X} i=1∑nXi−n×Xˉ
Not only will it not follow n n n And converges to zero , But with n n n An increase in , Its absolute value also tends to increase .
For the sake of completeness , The following simulation will be estimated according to the following logic π \pi π Value :
Know that the area of a circle is π r 2 \pi r^{2} πr2, We know the radius ( r r r ) by 1 The area of the circle is just π \pi π . If we put the circle perfectly on the side with 2 The square of ( That is, the area is 4) Internal , We know that the ratio of the area of a circle to the area of a square is π 4 \frac{\pi}{4} 4π.
therefore , If we randomly throw darts at a board of the same size several times , Then the ratio of darts in a circle to those that hit a square should be close to π 4 \frac{\pi}{4} 4π. If we multiply this ratio by 4, We got it π \pi π The estimate of .
# Create a dartboard
dart_board <- ggplot() +
geom_circle(aes(x0 = 0, y0 = 0, r = 1), fill = "black") +
geom_circle(aes(x0 = 0, y0 = 0, r = 0.99), fill = "red") +
geom_circle(aes(x0 = 0, y0 = 0, r = 0.7), fill = "lightyellow") +
geom_circle(aes(x0 = 0, y0 = 0, r = 0.2), fill = "red") +
geom_circle(aes(x0 = 0, y0 = 0, r = 0.1), fill = "darkgreen") +
coord_fixed() +
geom_segment(aes(x=-1,xend=1,y=1,yend=1)) +
geom_segment(aes(x=-1,xend=1,y=-1,yend=-1)) +
geom_segment(aes(x=1,xend=1,y=-1,yend=1)) +
geom_segment(aes(x=-1,xend=-1,y=-1,yend=1)) +
xlab("x")+ylab("y")+
theme_bw()
dart_board