R teaser



Classroom task


First we learned that if F(x) is a nice continuous distribution function (there exist a and b such that F(a)=0, F(b)=1, and F is strictly increasing on [a,b], where a can be minus infinity, b can be infinity) then the formula F^{-1} (RAND()) simulates a random variable having distribution function F(x). Then after some theoretical considerations, we approximated via simulation the probability of the event that the average of two independent identically distributed (i.i.d) random variables (RVs) with common density function f(x)= 2x, 0 < x < 1, lies between 0,25 and 0,75. After that, by modifying the worksheet, we also approximated the probability of the event that the average of four i.i.d. RVs with common density f(x) lies between 0,25 and 0,75. Then (see the second worksheet of the Excel file above) by plotting the sequence of averages we demonstrated the law of large numbers. It is worthwhile to resimulate the sequence by pressing the F9 key. Finally, I ran the R teaser script above.