6
m <- 12; n <- 12; k <- 15;
7
# mean and variances of the distribution of sample averages:
9
avg.var <- (k*m*n*(m+n-k)/((m+n)^2*(m+n-1)))/10;
10
# generate the entire data:
11
data <- matrix(rhyper(nn=10000, m=m, n=n, k=k), 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="Hypergeometric")
23
lines (x=normX, y=normY, type="l", col="red")
27
.rk.rerun.plugin.link(plugin="rkward::plot_hypergeometric_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=\nk.real=15.00\nm.real=12.00\nn.real=12.00\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=\nscalenorm.state=0", label="Run again")