(a)We say that the continuous random variable X has a uniform distribution on the interval (0,1) if the probability density of X is p(x)=1 for 0 < x < 1. Prove (mathematically) that E(X) =1/2 , and Var(X)=1/12.
(b) Simulate in Stata six random variables, x1, x2 ... x6, each
containing 100 independent observations distributed uniformly on (0,1)
(create, as usual, a log file called ab4.log, where ab are your
initials):
log using ab4.log, replace
set obs 100
generate x1 = uniform()
generate x2 = uniform()
...
generate x6 = uniform()
Create five additional variables that hold the row means for
two,
three,...,six of the variables x1 ... x6:
generate m2 = (x1+x2)/2
generate m3 = (x1+x2+x3)/3
...
generate m6 = (x1+x2+x3+x4+x5+x6)/6
(for example, the 100th element in m3 contains the average of the
100th
elements in x1, x2, x3)
Print the histograms of x1, m2, m4, m6:
graph x1,hist bin(10) normal xscale(0,1) yscale(0,.3)
graph m2,hist bin(10) normal xscale(0,1) yscale(0,.3)
graph m4,hist bin(10) normal xscale(0,1) yscale(0,.3)
graph m6,hist bin(10) normal xscale(0,1) yscale(0,.3)
(note that the histograms share the same scale; a normal curve is
approximated to each of them. You can try a histogram with
15 cells if you think it is more appropriate. If you work in UNIX,
you need to add at the end of the command: saving(filename)
and you'll end up with a PostScript file called filename.ps
which can be printed.)
Comment on the precision of the normal approximation rule,
as the sample size increases.
(c) Print a summary of the variables, containing the sample means and the sample standard deviations. What theoretical (numerical) values do the means and the standard deviations of x1 ... x6 approximate?
(d) What theoretical (numerical) values do the means of m1 ... m6 approximate?
(e) What theoretical (numerical) values do the standard deviations of m1 ... m6 approximate?
(f) Why are the numerical values in (d) and (e) only approximations of the corresponding theoretical values?