ConvergenceConcepts is an R package, built upon the tkrplot, tcltk and lattice packages, designed to investigate the convergence of simulated sequences of random variables. Four classical modes of convergence may be studied, namely: almost sure convergence (a.s.), convergence in probability (P), convergence in law (L) and convergence in
Many students are exposed, during their graduate school years, to the difficult concepts of convergence of a sequence of random variables (see Sethuraman (1995)). Indeed, as pointed out by Bryce, R. Gould, W. Notz and R. Peck, R (2001), “statistical theory is an important part of the curriculum, and is particularly important for students headed for graduate school”. Such knowledge is prescribed by learned statistics societies (see Accreditation of Statisticians by the Statistical Society of Canada, and Curriculum Guidelines for Undergraduate Programs in Statistical Science by the American Statistical Association). In the main textbooks (see for example Billingsley (1986), Chung (1974), Ferguson (1996), Lehmann (2001), Serfling (2002)), around 15 pages without graphs are allotted to defining these convergence concepts and their interrelations. But, very often, these concepts are only described through their definitions and some of their properties. Thus, some students may not fully visualize how a random variable converges to some limit. They also may not fully understand the differences between the various modes, especially between convergence in probability and almost surely.
Moreover, a statistician could be interested in whether or not a
specific random sequence converges. To explain the modes of convergence,
we could follow Bryce, R. Gould, W. Notz and R. Peck, R (2001)’s advice: “a modern statistical
theory course might, for example, include more work on computer
intensive methods”. With regard to the convergence in law, Dunn (1999)
and Marasinghe, W.Q. Meeker, D. Cook and T. Shin (1996) have proposed tools to explain this
concept in an interactive manner. Mills (2002) proposed a review of
statistical teaching based on simulation methods and Chance and A. Rossman (2006)
have written a book on this subject. Our package enables one to
investigate graphically the four classical modes of convergence of a
sequence of random variables: convergence almost surely, convergence in
probability, convergence in law and convergence in
The two main functions to use in our package are investigate
and
check.convergence
. The first one will be described in the next
section, investigating pre-defined Exercise 1 from
1. The second one will be described in the
last section, where it is shown how to treat your own examples.
At this point, note the necessary first two steps to perform before working with our package:
install.packages("ConvergenceConcepts")
require(ConvergenceConcepts)
Our package contains several pre-defined examples and exercises (all introduced and solved in 1 and in its associated online Appendix), some of which are classical ones. To investigate these examples, just type in the R console:
investigate()
Any entry can be selected by clicking in the left panel displayed in Figure 1. The corresponding text then appears inside the right panel. Next, by clicking the OK button, the relevant R functions are called to help the user to visualize the chosen modes of convergence for the random variable sequence under investigation. You will then be able to twiddle a few features.
For example, the first entry corresponds to the following problem.
Exercise 1: Let
Solution to exercise 1: The drawing on Figure 2
explains the construction of
Let us apply our visual reasoning as explained in Section 2 of
(Lafaye de Micheaux and B. Liquet 2009). Once a
This can be seen using our package. After having selected the first entry and clicked on the OK button displayed in Figure 1, we obtain the following plot.
On the left panel of this plot, we see some sample paths associated with
By definition,
By definition,
For the interested reader, a mathematically rigorous proof of this exercise can be found in 1.
We now introduce two new problems that have not been either pre-included
or treated in the package. We show how a user can define his own
functions in order to investigate the convergence of check.convergence
function.
This last function has several arguments whose description is now given.
nmax
: number of points in each sample path.
M
: number of sample paths to be generated.
genXn
: a function that generates the first
argsXn
: a list of arguments to genXn
.
mode
: a character string specifying the mode of convergence to be
investigated, must be one of "p"
(default), "as"
, "r"
or "L"
.
epsilon
: a numeric value giving the interval endpoint.
r
: a numeric value (r>0) if convergence in
nb.sp
: number of sample paths to be drawn on the left plot.
density
: if density
=TRUE
, then the plot of the density of density
=FALSE
, then the plot
of the distribution function
densfunc
: function to compute the density of
probfunc
: function to compute the distribution function of
tinf
: lower limit for investigating convergence in law.
tsup
: upper limit for investigating convergence in law.
trace
: function used to draw the plot; plot
or points
.
...
: optional arguments to trace
.
Problem 1: Let
Is
Is
Is
Is
Solution to problem 1:
We first define a random generator (called genYn
) for the check.convergence
.
genYn <- function(n) {
res <- (0.5)^(1:n)*rnorm(n,2,3)
return(res)
}
check.convergence(2000,500,genYn,mode="p")
We can zoom in the left panel of Figure 5 (from
We first define a random generator (called genTn
) for the
check.convergence
.
genTn <- function(n) {
res <- cumsum((0.5)^(1:n)*rnorm(n,2,3))-2
return(res)
}
check.convergence(2000,500,genTn,mode="p")
Each one of the sample paths rapidly evolve towards an horizontal
asymptote, not the same for each sample path, and not contained
inside the horizontal band
We first define a random generator (called genAn
) for the check.convergence
.
genAn <- function(n) {
x<-1:n
res<-cumsum((0.5)^x*rnorm(n,2,3))/cumsum(x)
return(res)
}
check.convergence(2000,500,genAn,mode="p")
In this case, we can zoom in (from
We first define a random generator (called genTnL
) for the check.convergence
.
genTnL <- function(n) {
res <- cumsum((0.5)^(1:n)*rnorm(n,2,3))
return(res)
}
check.convergence(2000,1000,genTnL,mode="L",
density = F,
densfunc = function(x){dnorm(x,2,sqrt(3))},
probfunc=function(x){pnorm(x,2,sqrt(3))},
tinf = -4, tsup = 4)
By definition,
We can move the slider (right part of Figure 8) and
see that the red curve comes closer to the black one. Also, on the
right you can see the tri-dimensional plot of
Problem 2: Let
Show that
Show that
Solution to problem 2:
We first define our random generator of the
genMn <- function(n) {
res <- cummax(runif(n))-1
return(res)
}
We now call the check.convergence
function.
check.convergence(2000,500,genMn,mode="p")
Obviously, all the sample paths are strictly increasing towards 1.
Looking at the right panel of Figure 9, we see
We now call the check.convergence
function to investigate the
quadratic mean convergence.
check.convergence(2000,500,genMn,mode="r",r=2)
By definition,
Looking at Figure 10, one can expect
We have described how this package can be used as interactive support
for asymptotics courses. A few examples were given to show how to
investigate almost sure convergence, convergence in probability,
convergence in law, or in
ConvergenceConcepts, tkrplot, tcltk, lattice
This article is converted from a Legacy LaTeX article using the texor package. The pdf version is the official version. To report a problem with the html, refer to CONTRIBUTE on the R Journal homepage.
Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Micheaux & Liquet, "ConvergenceConcepts: An R Package to Investigate Various Modes of Convergence", The R Journal, 2009
BibTeX citation
@article{RJ-2009-011, author = {Micheaux, Pierre Lafaye de and Liquet, Benoit}, title = {ConvergenceConcepts: An R Package to Investigate Various Modes of Convergence}, journal = {The R Journal}, year = {2009}, note = {https://rjournal.github.io/}, volume = {1}, issue = {2}, issn = {2073-4859}, pages = {18-25} }