6
shape <- 5.9; rate <- 0.3;
7
# mean and variances of the distribution of sample averages:
9
avg.var <- (shape/(rate^2))/10;
10
# generate the entire data:
11
data <- matrix(rgamma(n=10000, shape=shape, rate=rate), nrow=10);
12
# get the sample averages:
13
avg <- colMeans(data);
14
# generate random normal samples:
15
normX <- seq(from=min(avg), to=max(avg), length=1000);
16
normY <- dnorm (normX, mean = avg.exp, sd = sqrt(avg.var));
17
dist.hist <- hist(avg, plot=FALSE, breaks="Sturges");
18
# calculate the ylims appropriately:
19
ylim <- c(0,max(c(dist.hist$density, normY)));
22
plot(dist.hist, ylim=ylim, freq=FALSE, lty="solid", density=-1, xlab="Sample Averages", main="Gamma")
23
lines (x=normX, y=normY, type="l", col="red")
27
.rk.rerun.plugin.link(plugin="rkward::plot_gamma_clt", settings="drawnorm.state=1\nfunction.string=hist\nhistogram_opt.addtoplot.state=\nhistogram_opt.barlabels.state=\nhistogram_opt.density.real=-1.00\nhistogram_opt.doborder.state=1\nhistogram_opt.freq.state=0\nhistogram_opt.histbordercol.color.string=\nhistogram_opt.histbreaksFunction.string=Sturges\nhistogram_opt.histlinetype.string=solid\nhistogram_opt.rightclosed.state=1\nhistogram_opt.usefillcol.state=\nnAvg.real=10.00\nnDist.real=1000.00\nnormlinecol.color.string=red\nnormpointtype.string=l\nplotoptions.add_grid.state=0\nplotoptions.asp.real=0.00\nplotoptions.main.text=\nplotoptions.pointcolor.color.string=\nplotoptions.pointtype.string=\nplotoptions.sub.text=\nplotoptions.xaxt.state=\nplotoptions.xlab.text=\nplotoptions.xlog.state=\nplotoptions.xmaxvalue.text=\nplotoptions.xminvalue.text=\nplotoptions.yaxt.state=\nplotoptions.ylab.text=\nplotoptions.ylog.state=\nplotoptions.ymaxvalue.text=\nplotoptions.yminvalue.text=\nrate.real=0.3\nscalenorm.state=0\nshape.real=5.9", label="Run again")