[R] rcauchy density distribution

Peter Ehlers ehlers at ucalgary.ca
Wed Dec 1 01:18:19 CET 2010


On 2010-11-30 15:52, David Hervas Marin wrote:
> Hello, I'm taking samples from certain distributions and drawing a density
> distribution over the histogram of the samples
> It works fine for the chi-square and for the normal, but not for the cauchy. Any
> idea what I'm doing wrong? Thanks

Not doing anything wrong, really. But do check

  range(x)

Should be quite a range; that's what 'heavy tails' means.
To see the fit, try this:

  hist(x, freq=FALSE, breaks=5000, xlim=c(-6,6))
  curve(dcauchy(x), col = 2, add = TRUE)

Peter Ehlers

>
> x<- rchisq(10000, df = 4)
> hist(x, freq = FALSE, breaks=100)
> curve(dchisq(x, df = 4), col = 2, add = TRUE)
>
> x<- rnorm(10000)
> hist(x, freq = FALSE, breaks=100)
> curve(dnorm(x), col = 2, add = TRUE)
>
> x<- rcauchy(10000)
> hist(x, freq = FALSE, breaks=100)
> curve(dcauchy(x), col = 2, add = TRUE)
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list