GaryBAYLOR / R-code

A collection of algorithms written by myself for solving statistical problems
0 stars 0 forks source link

Cauchy distribution doesn't have mean #2

Open GaryBAYLOR opened 9 years ago

GaryBAYLOR commented 9 years ago

The mean of Cauchy distribution doesn't exist, which can be show by the following example. Create a random vector x1, x2, ..., x1000 of Cauchy distribution. Then calculate Yi = mean(x1 + ... + xi). At last, plot the sequence of Yi. Thus you can have a glance at how Yi goes as i increases from 1 to 1000. The following is R code.

crazyCauchy <- function() {
rv <- rcauchy(1e3)
x <- numeric(1e3)
for(i in 1:1e3) {
    x[i] <- mean(rv[1:i])
}
plot(x, pch = 19, cex = 0.5)
}

Running the function and the plot looks this this. image image image There is no trend of convergence.