We can use the LLN to estimate the Expected Value of any Random Variable, if we can generate IID draws of that Random Variable. Suppose X1, X2, ... are IID draws of a Gamma Random Variable. We will show how to verify the LLN using EXCEL. The Mean and Variance of Gamma (p,lambda) variables have already been derived. We will look at the averages of sequences of IID Gamma Variables and see how they converge to the theoretical expected values. This is all done in the EXCEL spreadsheet attached. The elements of the spreadsheet are discussed below.
Cells C1 and C2 Contain values of P and Lambda for the Gamma. These can be VARIED by the Student, to see the effect on the Graph.
Cells A2:A401 contain 400 Gamma Random Variables. These are generated using: =GAMMA.INV(RAND(),$C$1,1/$C$2). Note that EXCEL uses 1/Lambda to define its Gamma Density Function. What we have called Lambda in our definition is 1/Lambda in their function.
Cells B11:B401 contain AVERAGES of these Post-Experimental OBSERVED outcomes of Gamma Random Variables. Cell B11 contains the following entry:
B11 ENTRY: =AVERAGE($A$2:A11). This averages the first 10 observed outcomes. When this is copied down, each cell B(i) contains the average from cell A2 to A(i). So we are looking at averages of more and more Gamma RV's. These averages are plotted in the top graph.
We get more insight into the averages when we plot the EXPECTED Value P/Lambda. This is the straight line in the second graph. This is the EXPECTED VALUE of the average A(N) which remains the same for all N. The OBSERVED averages of outcomes converge to this expected value for large N, as the graph shows.
Note that the VARIANCE of A(N) is Var(X)/N -- the variance of the average is the SUM of N Variances of X1 to XN but divided by N^2. The sum is N times the variance of 1 Variable, but after dividing by N^2, the variance of the average become Variance of ONE RV divided by N. The SQUARE ROOT of Var/N is the Standard Error of the Average. Generally speaking, Averages remain with 2 Standard Errors of the Expected value with a high probability of around 95%. The second graph shows these error bounds. EX - 2*SE and EX + 2*SE are plotted -- the graph of the averages should remain within these two bounds. Note how the bounds become tighter and N increases, since SE of A(N) decreases to 0. This shows how the LLN operates -- the range of possible fluctuations in the average lies in the reducing narrow bound around EX.
The ENTRIES for the Standard Error are produced by taking EX and adding or subtracting 2*SE, where SE=Sqrt(Var)/Sqrt(ROW()-1). The EXCEL ROW() function just returns the ROW number, which is one more than the number of observations N, since the random variables start at row 2. The numerator is the SE of a single random variable, while the denominator is the SQRT of the number of observations.