R/rtrnorm.R

Defines functions rtrnorm

## File Name: rtrnorm.R
## File Version: 0.10

####################################################################
# sampling from a truncated normal distribution
rtrnorm <- function( N, mean, sd, lower=rep(-Inf,N), upper=rep(Inf,N) )
{
    t1 <- stats::pnorm( lower, mean=mean, sd=sd )
    t2 <- stats::pnorm( upper, mean=mean, sd=sd )
    rn <- stats::runif( N, t1, t2 )
    stats::qnorm( rn, mean=mean, sd=sd )
}
####################################################################

Try the immer package in your browser

Any scripts or data that you put into this service are public.

immer documentation built on Aug. 22, 2022, 5:05 p.m.