# drayleigh: The Rayleigh distribution. In bayesmeta: Bayesian Random-Effects Meta-Analysis

## Description

Rayleigh density, distribution, quantile function and random number generation.

## Usage

 ```1 2 3 4``` ``` drayleigh(x, scale=1, log=FALSE) prayleigh(q, scale=1) qrayleigh(p, scale=1) rrayleigh(n, scale=1) ```

## Arguments

 `x, q` quantile. `p` probability. `n` number of observations. `scale` scale parameter (>0). `log` logical; if `TRUE`, logarithmic density will be returned.

## Details

The Rayleigh distribution arises as the distribution of the square root of an exponentially distributed (or χ^2_2-distributed) random variable. If X follows an exponential distribution with rate λ and expectation 1/λ, then Y=sqrt(X) follows a Rayleigh distribution with scale sigma=1/sqrt(2*lambda) and expectation sqrt(pi/(4*lambda)).

Note that the exponential distribution is the maximum entropy distribution among distributions supported on the positive real numbers and with a pre-specified expectation; so the Rayleigh distribution gives the corresponding distribution of its square root.

## Value

`drayleigh()`’ gives the density function, ‘`prayleigh()`’ gives the cumulative distribution function (CDF), ‘`qrayleigh()`’ gives the quantile function (inverse CDF), and ‘`rrayleigh()`’ generates random deviates.

## Author(s)

Christian Roever [email protected]

## References

N.L. Johnson, S. Kotz, N. Balakrishnan. Continuous univariate distributions, volume 1. Wiley, New York, 2nd edition, 1994.

`dexp`, `dlomax`, `dhalfnormal`, `dhalft`, `dhalfcauchy`, `TurnerEtAlPrior`, `RhodesEtAlPrior`, `bayesmeta`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32``` ```######################## # illustrate densities: x <- seq(0,6,le=200) plot(x, drayleigh(x, scale=0.5), type="l", col="green", xlab=expression(tau), ylab=expression("probability density "*f(tau))) lines(x, drayleigh(x, scale=1/sqrt(2)), col="red") lines(x, drayleigh(x, scale=1), col="blue") abline(h=0, v=0, col="grey") ############################################### # illustrate exponential / Rayleigh connection # via a quantile-quantile plot (Q-Q-plot): N <- 10000 exprate <- 5 plot(sort(sqrt(rexp(N, rate=exprate))), qrayleigh(ppoints(N), scale=1/sqrt(2*exprate))) abline(0, 1, col="red") ############################################### # illustrate Maximum Entropy distributions # under similar but different constraints: mu <- 0.5 tau <- seq(0, 4*mu, le=100) plot(tau, dexp(tau, rate=1/mu), type="l", col="red", ylim=c(0,1/mu), xlab=expression(tau), ylab="probability density") lines(tau, drayleigh(tau, scale=1/sqrt(2*1/mu^2)), col="blue") abline(h=0, v=0, col="grey") abline(v=mu, col="darkgrey"); axis(3, at=mu, label=expression(mu)) # explicate constraints: legend("topright", pch=15, col=c("red","blue"), c(expression("Exponential: E["*tau*"]"==mu), expression("Rayleigh: E["*tau^2*"]"==mu^2))) ```

### Example output

```Loading required package: forestplot