# Law of large numbers, an exercise

• Mar 3rd 2013, 05:36 PM
spudwish
Law of large numbers, an exercise
This isn't advanced statistics but I think this subforum is better to post this question in:

I have a lab that's supposed to illustrate the law of large numbers (LLN), and we're using Matlab (this is not a Matlab question). First step is to create a "set of data with 300 observations from an exponential distribution with expected value 1", chanceno = exprnd(1,1,300). Then we create "a vector 'avg' with 300 elements where i is the average of the i first random numbers and produces a plot of this vector";

sums = cumsum(chanceno)
for i=1:length(chanceno)
avg(i)=sums(i)/i;
end
plot(avg)

This does indeed produce such a plot, which seems to converge to 1, the expected value, as per the law of large numbers. Now to my question: How does this illustrate LLN? My interpretation of all this (which was wrong) was that we're creating a dataset of 300, then one of these 300 is chosen according to an exponential distribution and repeated a bunch of times. I now realize this is wrong, very wrong, but I'm not sure why this exercise is about LLN. My problem is with "random numbers"; the formulation of LLN which I have in my book is that we have sequence of independent random (or stochastic) variables, etc etc. Should I view the generation of each of these 300 random numbers as a random variable? I.e. in the formulation of LLN I should view each of the 300 random numbers as an X_i, as in; "let X1,X2,... be a sequence of independent random variables with the same expected value mu and std.dev. sigma. Let \overline{X}_n := (1/n) \sum_{i=1}^n X_i be the average of the n first variables. Then for all \epsilon > 0, Pr(|\overline{X}_n - mu| > \epsilon) -> 0 as n -> \infty"

This is all a bit vague I suppose, but I hope someone understands what I'm asking. Thanks in advance.
• Mar 3rd 2013, 06:03 PM
chiro
Re: Law of large numbers, an exercise
Hey spudwish.

Every random number should be treated as a random variable drawn from a particular distribution (in this case, exponential).

This is actually the basic idea behind all of statistics: every element in the sample has a particular distribution and from that we derive a set of statistics (which is just a function of random variables).
• Mar 4th 2013, 09:56 AM
spudwish
Re: Law of large numbers, an exercise
Alright, then I'm on the right track at least. Thank you!