Let Z = X/Y where X and Y have normal densities with mean 0 and standard deviation 1. Then it can be shown that Z has a Cauchy density. (a) Write a program to illustrate this result by plotting a bar graph of 1000 samples obtained by forming the ratio of two standard normal outcomes. Compare your bar graph with the graph of the Cauchy density. Depend- ing upon which computer language you use, you may or may not need to tell the computer how to simulate a normal random variable. A method for doing this was described in Section 5.2. Normal distribution (b) We have seen that the Law of Large Numbers does not apply to the Cauchy density (see Example 8.8). Simulate a large number of experi- ments with Cauchy density and compute the average of your results. Do these averages seem to be approaching a limit? If so can you explain why this might be?
hist(rnorm(1000)/rnorm(1000), breaks=10000, xlim=c(-10,10),xlab="", ylab="",main="Histogram of X/Y Distribution")
Cauchy Distribution
hist(rcauchy(1000), breaks=10000, xlim=c(-10,10),xlab="", ylab="",main="Histogram of Cauchy Distribution")
The two distributions look very similar. Now let us run the following simulation 2,000 times. Each run will generate 1,000 outcomes and then calculate the average. According to the Law of Large Numbers, as number of runs increases the calculated value should approach the theoretical value. We do this for normal distribution and for Cauchy distribution.
trials <- 2000
dist_cauchy <- rep(0,trials)
avg_cauchy <- rep(0,trials)
dist_norm <- rep(0,trials)
avg_norm <- rep(0,trials)
for (n in 1:trials) {
dist_cauchy[n]<-mean(rnorm(1000)/rnorm(1000))
dist_norm[n]<-mean(rnorm(1000))
avg_cauchy[n]<-mean(dist_cauchy[1:n])
avg_norm[n]<-mean(dist_norm[1:n])
}
plot(avg_norm, xlab="No of Trials", ylab="",main="Estimate of Mean of Normal Distribution")
In the simulated normal distribution the value approaches 0
plot(avg_cauchy, xlab="No of Trials", ylab="",main="Estimate of Mean of Cauchy Distribution")
For the Cauchy distribution, average/mean is not defined and from the plot we can see that it does jump around