rectNormal: Rectified Normal Distribution

drectnormR Documentation

Rectified Normal Distribution

Description

Density, cumulative distribution, quantile functions and random number generation for the Rectified Normal distribution.

Usage

drectnorm(q, mu = 0, sigma = 1, log = FALSE)

prectnorm(q, mu = 0, sigma = 1)

qrectnorm(p, mu = 0, sigma = 1)

rrectnorm(n = 1, mu = 0, sigma = 1)

Arguments

q

vector of quantiles.

mu

vector of location parameters (means).

sigma

vector of scale parameters.

log

if TRUE, then probabilities are returned in logarithms.

p

vector of probabilities.

n

number of observations. Should be a single number.

Details

If x~N(mu, sigma^2) then y = max(0, x) follows Rectified Normal distribution: y~RectN(mu, sigma^2), which can be written as:

f_y = 1(x<=0) F_x(mu, sigma) + 1(x>0) f_x(x, mu, sigma),

where F_x is the cumulative distribution function and f_x is the probability density function of normal distribution.

Both prectnorm and qrectnorm are returned for the lower tail of the distribution.

All the functions are defined for non-negative values only.

Value

Depending on the function, various things are returned (usually either vector or scalar):

  • drectnorm returns the density function value for the provided parameters.

  • prectnorm returns the value of the cumulative function for the provided parameters.

  • qrectnorm returns quantiles of the distribution. Depending on what was provided in p, mu and sigma, this can be either a vector or a matrix, or an array.

  • rrectnorm returns a vector of random variables generated from the RectN distribution. Depending on what was provided in mu and sigma, this can be either a vector or a matrix or an array.

Author(s)

Ivan Svetunkov, ivan@svetunkov.com

See Also

Distributions

Examples

x <- drectnorm(c(-1000:1000)/200, 0, 1)
plot(c(-1000:1000)/200, x, type="l")

x <- prectnorm(c(-1000:1000)/200, 0, 1)
plot(c(-1000:1000)/200, x, type="l")

qrectnorm(c(0.025,0.975), 0, c(1,2))

x <- rrectnorm(1000, 0, 1)
hist(x)


config-i1/greybox documentation built on Dec. 12, 2024, 1:42 p.m.