R/truncnorm2.R

truncnorm2 <-
function (l, u, m, sd, n) 
{
    l1 <- pnorm((l - m)/sd)
    u1 <- pnorm((u - m)/sd)
    x <- runif(n, l1, u1)
    if (x == 0) {
        y = u
    }
    else {
        if (x == 1) {
            y = l
        }
        else {
            y <- qnorm(x) * sd + m
        }
    }
    return(y)
}

Try the HSROC package in your browser

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

HSROC documentation built on Sept. 19, 2019, 9:05 a.m.