dist.HalfNorm: Half-Normal Distribution

Description Usage Arguments Details Value See Also Examples

Description

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

Usage

1
2
3
4
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 <= x], otherwise, Pr[X > x].

Details

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
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"))

Example output



LaplacesDemon documentation built on July 9, 2021, 5:07 p.m.