File:LawOfLargeNumbersCauchy.svg

Summary

Description
English: Sample means of indepedent random variables from the standard Cauchy distribution. This figure is intended to illustrate a hypothesis "a distribution has a finite mean" in the law of large numbers is necessary.
Date
Source Own work
Author ARAKI Satoru
library(ggplot2)
library(latex2exp)

set.seed(2018)

# Number of samples:
N <- 3000
# Three series of indepedent N samples from the standard Cauchy distribution:
x1 <- rcauchy(N); x2 <- rcauchy(N); x3 <- rcauchy(N)
# Sample means:
m <- function(x) {
  return(sapply(1:N, function(n) mean(x[1:n])))
}
m1 <- m(x1); m2 <- m(x2); m3 <- m(x3)

d1 <- data.frame(x=1:N, y=m1, w=sapply(1:N, function(n) "1"))
d2 <- data.frame(x=1:N, y=m2, w=sapply(1:N, function(n) "2"))
d3 <- data.frame(x=1:N, y=m3, w=sapply(1:N, function(n) "3"))
data <- rbind(d1, d2, d3)

fig <- ggplot(data) +   
  geom_hline(yintercept=0, alpha=.5) +
  geom_line(aes(x=x, y=y, color=w)) + 
  labs(x=TeX("$n$"), y=TeX("$(x_1 + \\cdots + x_n)/n$")) +
  guides(color=FALSE)

svg(filename="LawOfLargeNumbersCauchy.svg", width=16/2, height=9/2)
plot(fig)
dev.off()

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Category:CC-BY-SA-4.0#LawOfLargeNumbersCauchy.svgCategory:Self-published work
Category:Ggplot2 Category:Statistics Category:Valid SVG Category:Law of large numbers Category:Images with R source code
Category:CC-BY-SA-4.0 Category:Ggplot2 Category:Images with R source code Category:Law of large numbers Category:Self-published work Category:Statistics Category:Valid SVG