dist.HalfNorm: Half-Normal Distribution

dist.HalfNormalR Documentation

Half-Normal Distribution

Description

These functions provide the density, distribution function, quantile function, and random generation for the half-normal distribution.

Usage

dhalfnorm(x, scale=sqrt(pi/2), log=FALSE)
phalfnorm(q, scale=sqrt(pi/2), lower.tail=TRUE, log.p=FALSE)
qhalfnorm(p, scale=sqrt(pi/2), lower.tail=TRUE, log.p=FALSE)
rhalfnorm(n, scale=sqrt(pi/2))

Arguments

x, q

These are each a vector of quantiles.

p

This is a vector of probabilities.

n

This is the number of observations, which must be a positive integer that has length 1.

scale

This is the scale parameter \sigma, which must be positive.

log, log.p

Logical. If log=TRUE, then the logarithm of the density or result is returned.

lower.tail

Logical. If lower.tail=TRUE (default), probabilities are Pr[X \le x], otherwise, Pr[X > x].

Details

  • Application: Continuous Univariate

  • Density: p(\theta) = \frac{2 \sigma}{\pi} \exp(-\frac{\theta^2 \sigma^2}{\pi}), \quad \theta \ge 0

  • Inventor: Derived from the normal or Gaussian

  • Notation 1: \theta \sim \mathcal{HN}(\sigma)

  • Notation 2: p(\theta) = \mathcal{HN}(\theta | \sigma)

  • Parameter 1: scale parameter \sigma > 0

  • Mean: E(\theta) = \frac{1}{\sigma}

  • Variance: var(\theta) = \frac{\pi-2}{2 \sigma^2}

  • Mode: mode(\theta) = 0

The half-normal distribution is recommended as a weakly informative prior distribution for a scale parameter that may be useful as an alternative to the half-Cauchy, half-t, or vague gamma.

Value

dhalfnorm gives the density, phalfnorm gives the distribution function, qhalfnorm gives the quantile function, and rhalfnorm generates random deviates.

See Also

dnorm, dnormp, and dnormv.

Examples

library(LaplacesDemon)
x <- dhalfnorm(1)
x <- phalfnorm(1)
x <- qhalfnorm(0.5)
x <- rhalfnorm(10)

#Plot Probability Functions
x <- seq(from=0.1, to=20, by=0.1)
plot(x, dhalfnorm(x,0.1), ylim=c(0,1), type="l", main="Probability Function",
     ylab="density", col="red")
lines(x, dhalfnorm(x,0.5), type="l", col="green")
lines(x, dhalfnorm(x,1), type="l", col="blue")
legend(2, 0.9, expression(sigma==0.1, sigma==0.5, sigma==1),
     lty=c(1,1,1), col=c("red","green","blue"))

LaplacesDemonR/LaplacesDemon documentation built on April 1, 2024, 7:22 a.m.