# dist.HalfNorm: Half-Normal Distribution In LaplacesDemon: Complete Environment for Bayesian Inference

## 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

• Application: Continuous Univariate

• Density: p(theta) = 2*sigma/pi e^-(theta^2*sigma^2/pi), theta >= 0

• Inventor: Derived from the normal or Gaussian

• Notation 1: theta ~ HALF-N(sigma)

• Notation 2: p(theta) = HN(theta | sigma)

• Parameter 1: scale parameter sigma > 0

• Mean: E(theta) = 1 / sigma

• Variance: var(theta) = (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.

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.