# How to demonstrate failure of CLT in R?

I was assigned to demonstrate the Central Limit Theorem (CLT) in R in my statistics class. I already made some progress with simulation using simple.sim in R. I want to prepare 3 examples of the CLT with continuous distributions (rnorm, rt and rf) and 3 examples with discrete distributions (rbinom, rpois and rtriangle for triangle distribution). I also want to demonstrate the failure of the CLT. I realized that this could happen when the variance of the distribution does not converge. I can't find any discrete distribution that has non-converging variance and is implemented in R.

• A minor point: The Cauchy distribution does not have infinite variance; in fact, it does not have a variance at all !! Commented Oct 31, 2011 at 18:36
• Let $X$ be a discrete random variable taking values in $1,2,\ldots$. Setting $\Pr[X\le k] = 1-1/(k+1)^2$, $k=1,2,\ldots,$ defines a probability distribution easily shown to have finite mean but whose variance does not converge. The simple expression for its CDF makes it easy to sample from this distribution (take the floor of the reciprocal of a uniform(0,1) variate).
– whuber
Commented Oct 31, 2011 at 19:07
• Before you accumulate more questions, please edit this one so that people can make sense of it.
– whuber
Commented Oct 31, 2011 at 19:40
• How could I generate random samples of the distribution with pdf like you mentioned before in R? Commented Oct 31, 2011 at 20:05
• I cant actually understand you about the CDF function. How could I get one? I am not good with inverse transform sampling, but as far as i know i need to take $\int 1-1/(k+1)^2 dk= k + \frac{1}{k+1}$. Then i have to find a inverse function for this, which i dunno how. Then i will have to apply this function for every element in for example runif(100, min=0,max=1) ? Commented Oct 31, 2011 at 20:36

If you want to take a different approach to when the CLT does not apply, you could focus on the method of sampling rather than the distribution being sampled from. This approach could either impress your professor or violate the rules of the assignment (so read the assignment carefully).

The CLT mainly applies to an SRS (simple random sample) and some other similar cases. But, what we often skip over in the intro classes (and later classes) is what happens with other sampling schemes. For example consider doing a random-digit-dialing sample for a phone interview where one of the variables we are interested in is household income, since higher income households are also likely to have more phone numbers on average this will be a biased sample (unless you use a weighted mean). So you could demonstrate sampling from a normal population (or other distribution), but with the probability of being in the sample related to the outcome of interest, then show how the unweighted mean and weighted mean behave.

You could also look at cluster sampling or stratified sampling or other forms of sampling and show how the parameter estimates behave under a naive approach compared to the proper approach.

• That's very interesting approach.. Commented Jun 12, 2012 at 22:24

Well it's hard to know if you're "doing everything correct" without actually seeing what it is you're doing.

You are correct in that the cauchy distribution is a case where the CLT doesn't apply. I don't know what you're looking for when you say " a uniform distribution with infinite variance" because any uniform distribution needs to be bounded and any bounded random variable will have finite variance. If you're looking for a uniform distribution over the entire real line then I'm afraid you're out of luck since that distribution isn't actually a distribution.

Another way to derive a case where the CLT doesn't hold is by instead of considering independent and identically distribution random variables you could consider a sequence of independent random variables where the variance is getting larger (in a specific way) with every new draw.

• Actually a CLT does apply to the Cauchy, just not the usual one. The Cauchy is its own domain of attraction under means! Commented Oct 31, 2011 at 19:09
• Jacobian, what people are struggling with is that you seem to be using "uniform" in a non-standard sense. The CLT does work with uniform distributions. No Poisson distribution is uniform. So what distinction are you really trying to make where you write "uniform"?
– whuber
Commented Oct 31, 2011 at 19:27
• yeah my mistake about the variance. To be precise the question should sound like this: I want to demonstrate with some descrete distributions that CLT doesn't work. What I found out from your letter is that to make this work i should take for example poisson distribution and every simulation i should increase λ by one, and then the it wont follow CLT? Commented Oct 31, 2011 at 20:39