Law of Large Numbers Demonstration

Simulate a large number of iid random variables. Then compute a list of means (((Subscript[X, 1])+(Subscript[X, 2])+⋯+(Subscript[X, n]))/n) for n=1,2,3....

num=100000;
dist = BinomialDistribution[8,.3];
μ=Mean[dist];
vals=RandomVariate[dist,num];
means=Table[Mean[vals[[1;;n]]],{n,1,num}];
Print["Generated ",num," values from ",dist,"; individual mean is ",μ,"."]

ListPlot[means,PlotRange->All]

Animate[
Show[ListPlot[means[[1;;n]],PlotRange->{2.2,2.6}],Plot[2.4,{x,0,n},PlotStyle->Orange]]
,{n,1,100000,10}]