~l3on/ubuntu/precise/rkward/rebuild1

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Friedrichsmeier
  • Date: 2009-10-26 14:30:00 UTC
  • mfrom: (1.1.13 upstream) (6.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20091026143000-wzwt6cryjnwce23k
Tags: 0.5.2-1
* new upstream release
  closes: #551306 (added support for the new dynamic help system)
* Add "DM-Upload-Allowed: yes" in control
* bump standards version to 3.8.3 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
local({
 
2
## Prepare
 
3
## Compute
 
4
## Print result
 
5
# parameters:
 
6
mean <- 0.0; sd <- 1.00;
 
7
# mean and variances of the distribution of sample averages:
 
8
avg.exp <- exp(mean+sd^2/2);
 
9
avg.var <- (exp(2*mean+sd^2)*(exp(sd^2)-1))/10;
 
10
# generate the entire data:
 
11
data <- matrix(rlnorm(n=10000, meanlog=mean, sdlog=sd), 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="Scott");
 
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=7, angle=45, border=FALSE, xlab="Sample Averages", main="Lognormal")
 
23
        lines (x=normX, y=normY, type="l", col="red")
 
24
})
 
25
rk.graph.off ()
 
26
})
 
27
.rk.rerun.plugin.link(plugin="rkward::plot_log_normal_clt", settings="drawnorm.state=1\nfunction.string=hist\nhistogram_opt.addtoplot.state=\nhistogram_opt.angle.real=45\nhistogram_opt.barlabels.state=\nhistogram_opt.density.real=7.00\nhistogram_opt.doborder.state=\nhistogram_opt.freq.state=0\nhistogram_opt.histbreaksFunction.string=Scott\nhistogram_opt.histlinetype.string=solid\nhistogram_opt.rightclosed.state=1\nhistogram_opt.usefillcol.state=\nmean.real=0.0\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\nsd.real=1.00", label="Run again")
 
28
.rk.make.hr()