简体   繁体   中英

Plot histogram of Cauchy distribution in R

I'm trying to plot an histogram of the Cauchy distribution in R using the following code:

X = rcauchy(10^5)
hist(X)

and no matter what options I try in the hist() function, I can never see more than two bars on my histogram (basically one for negative values and one for positive values).

It works fine, however, when I use the normal distribution (or others).

This results from the properties of the distribution.

Most values are relatively close to zero, but very large absolute values are much more probable than for the normal distribution. There are about 1 % values with an absolute value greater than 50, and 0.1 % greater than 500.

Try plotting only part of the values:

hist(X[abs(X)<1])
hist(X[abs(X)<5])
hist(X[abs(X)<50])
hist(X)

You can also look at the cumulative distribution function:

plot(ecdf(X))

And check the boxplot:

boxplot(X)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM