Normal_ct: The Central Normal Distribution

Description Usage Arguments Details Value Examples

Description

Distribution function and random generation for the center (between a lower and an upper bound) of the normal distribution with mean equal to mu and standard deviation equal to sigma.

Usage

1
2
3
pnorm_ct(a = -Inf, b = Inf, mu = 0, sigma = 1, log.p = TRUE, Diff = FALSE)

rnorm_ct(n, lgrt, lglt, mu = 0, sigma = 1)

Arguments

a

lower bound

b

upper bound

mu

mean parameter

sigma

standard deviation

log.p

Logical argument. If TRUE, the log probability is provided

Diff

Logical argument. If TRUE the second parameter is the difference between the lower and upper bound

n

number of draws to generate. If length(n) > 1, the length is taken to be the number required

lgrt

log of the distribution function between the lower bound and infinity

lglt

log of the distribution function between negative infinity and the upper bound

Details

The distribution function pnorm_ct finds the probability of the center of a normal density (the probability of the area between a lower bound a and an upper bound b) while the random number generator rnorm_ct samples from a restricted normal density where lgrt is the log of the distribution between the lower bound and infinity and lglt is the log of the distribution function between negative infinity and the upper bound. The sum of the exponentiated values for the two (exp(lgrt)+exp(lglt)) must sum to more than 1.

These functions are mainly used to handle cases where the differences between the upper and lower bounds b-a are small. In such cases, using pnorm(b)-pnorm(a) may result in 0 being returned even when the difference is supposed to be positive.

Value

For pnorm_ct, vector of length equal to length of a and for rnorm_ct, a vector with length determined by n containing draws from the center of the normal distribution.

Examples

1
2
3
4
5
6
7
8
pnorm_ct(0.2,0.4)
exp(pnorm_ct(0.2,0.4))
pnorm_ct(0.2,0.4,log.p=FALSE)
log(pnorm_ct(0.2,0.4,log.p=FALSE))
## Example where difference between two pnorm calls fail
## but call to pnorm_ct works
pnorm(0.5)-pnorm(0.4999999999999999)
pnorm_ct(0.4999999999999999,0.5,log.p=FALSE)

knygren/glmbayes documentation built on Sept. 4, 2020, 4:39 p.m.