Learn R Programming

extraDistr (version 1.8.1)

Wald: Wald (inverse Gaussian) distribution

Description

Density, distribution function and random generation for the Wald distribution.

Usage

dwald(x, mu, lambda, log = FALSE)
pwald(q, mu, lambda, lower.tail = TRUE, log.p = FALSE)
rwald(n, mu, lambda)

Arguments

x, q
vector of quantiles.
mu, lambda
location and shape parameters. Scale must be positive.
log, log.p
logical; if TRUE, probabilities p are given as log(p).
lower.tail
logical; if TRUE (default), probabilities are $P[X \le x]$ otherwise, $P[X > x]$.
n
number of observations. If length(n) > 1, the length is taken to be the number required.
p
vector of probabilities.

Details

Probability density function $$ f(x) = \sqrt{\frac{\lambda}{2\pi x^3}} \exp\left( \frac{-\lambda(x-\mu)^2}{2\mu^2 x} \right) $$

Cumulative distribution function $$ F(x) = \Phi\left(\sqrt{\frac{\lambda}{x}} \left(\frac{x}{\mu}-1 \right) \right) + \exp\left(\frac{2\lambda}{\mu} \right) \Phi\left(\sqrt{\frac{\lambda}{x}} \left(\frac{x}{\mu}+1 \right) \right) $$

Examples

Run this code

x <- rwald(1e5, 5, 16)
xx <- seq(0, 100, by = 0.001)
hist(x, 100, freq = FALSE)
lines(xx, dwald(xx, 5, 16), col = "red")
hist(pwald(x, 5, 16))
plot(ecdf(x))
lines(xx, pwald(xx, 5, 16), col = "red", lwd = 2)

Run the code above in your browser using DataLab