~ubuntu-branches/debian/sid/rkward/sid

« back to all changes in this revision

Viewing changes to tests/distributions/RKTestStandard.hypergeometric_clt.rkcommands.R

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Friedrichsmeier
  • Date: 2011-10-23 15:30:00 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: james.westby@ubuntu.com-20111023153000-3gutwgotykvcm67s
Tags: 0.5.7-1
* new upstream release
* provide build-arch and build-indep targets
* include buildflags as instructed by the dpkg developers

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
local({
2
 
## Prepare
3
 
## Compute
4
 
## Print result
5
 
# parameters:
6
 
m <- 12; n <- 12; k <- 15;
7
 
# mean and variances of the distribution of sample averages:
8
 
avg.exp <- k*m/(m+n);
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)));
20
 
rk.graph.on ()
21
 
try ({
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")
24
 
})
25
 
rk.graph.off ()
26
 
})
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")
28
 
.rk.make.hr()