Functions for generating a sequence of plots of randomly generated replicates of \(\bar X_n= \frac{1}{n} \sum_{i=1}^n X_i\) for sums of iid r.v. distributed according to a prescribed discrete or absolutely continuous distribution. A line for the expectation and CLT based (pointwise) 95%-confidence bands are also plotted and the empirical coverage of this band by the replicated plotted so far is indicated.
illustrateLLN(Distr = Norm(),n = c(1,3,5,10,25,50,100,500,1000,10000),
m = 50, step = 1, sleep = 0, withConf = TRUE,
withCover = (length(n)
void
object of class "UnivariateDistribution"
:
distribution of the summands
vector of integers: sample sizes to be considered
integer: (total) number of replicates to be plotted subsequently
integer: number of replicates to be drawn at once
numeric: pause in seconds between subsequent plots
logical: shall a line for the limiting expectation
(in case of class Cauchy
instead: median)
be drawn?
logical: shall (CLT-based) confidence bands be plotted?
logical: shall empirical coverage of (CLT-based) confidence bands be printed?
logical: shall a legend be included?
character: type of confidence interval ---"CLT" or "Chebyshev"; partial matching is used; if this fails "CLT" is used.
numerical: nominal coverage of the confidence bands ---to be in (0,1)
character or integer code; color for confidence bands
integer code (see par
);
line width of the confidence bands
integer code (see par
);
line type of the confidence bands
character or integer code; color for confidence bands
integer code (see par
);
line width of the confidence bands
integer code (see par
);
line type of the confidence bands
magnification w.r.t. the current setting of cex
to be used for empirical coverages; as in
par
magnification w.r.t. the current setting of cex
to be used for the legend as in
par
further arguments to be passed to matplot
,
matlines
, abline
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de
illustrateLLN
generates a sequence of plots.
Any parameters of plot.default
may be passed on to this particular
plot
method.
There are default main
titles as well as xlab
and ylab
annotations.
In all title arguments, the following patterns are substituted:
"%C"
class of argument x
"%P"
parameters of x
in form of a comma-separated list of
<value>'s coerced to character
"%Q"
parameters of x
in form of a comma-separated list of
<value>'s coerced to character and in parenthesis --- unless
empty; then ""
"%N"
parameters of x
in form of a comma-separated list
<name> = <value> coerced to character
"%A"
deparsed argument x
"%D"
time/date-string when the plot was generated
"%X"
the expression \(\bar X_n=\sum_{i=1}^n X_i/n\)
If not explicitly set, col.Eline
, col.Conf
are set
to col
if this arg is given and else to their default values as given
above. Similarly for cex
, lwd
and lty
.
illustrateLLN(Distr = Unif())
illustrateLLN(Distr = Pois(lambda = 2))
illustrateLLN(Distr = Pois(lambda = 2)+Unif())
illustrateLLN(Td(3), m = 50, col.Eline = "green", lwd = 2, cex = 0.6, main =
"My LLN %C%Q", sub = "generated %D")
illustrateLLN(Td(3), m = 50, CLTorCheb = "Chebyshev")
illustrateLLN(Td(3), m = 50, CLTorCheb = "Chebyshev", coverage = 0.75)
Run the code above in your browser using DataLab