R/truncnorm.R In truncnorm: Truncated Normal Distribution

Documented in dtruncnormetruncnormptruncnormqtruncnormrtruncnormvtruncnorm

```##
## truncnorm.R - Interface to truncnorm.c
##
## Authors:
##  Heike Trautmann  <trautmann@statistik.uni-dortmund.de>
##  Detlef Steuer    <detlef.steuer@hsu-hamburg.de>
##  Olaf Mersmann    <olafm@statistik.uni-dortmund.de>
##

dtruncnorm <- function(x, a=-Inf, b=Inf, mean=0, sd=1)
.Call(C_do_dtruncnorm, as.numeric(x),
as.numeric(a), as.numeric(b), as.numeric(mean), as.numeric(sd))

ptruncnorm <- function(q, a=-Inf, b=Inf, mean=0, sd=1)
.Call(C_do_ptruncnorm, as.numeric(q),
as.numeric(a), as.numeric(b), as.numeric(mean), as.numeric(sd))

qtruncnorm <- function(p, a=-Inf, b=Inf, mean=0, sd=1)
.Call(C_do_qtruncnorm, as.numeric(p),
as.numeric(a), as.numeric(b), as.numeric(mean), as.numeric(sd))

rtruncnorm <- function(n, a=-Inf, b=Inf, mean=0, sd=1) {
stopifnot(length(a) > 0,
length(b) > 0,
length(mean) > 0,
length(sd) > 0)
if (length(n) > 1)
n <- length(n)
else if (!is.numeric(n))
stop("non-numeric argument n.")
else if (n == 0)
return(NULL)
.Call(C_do_rtruncnorm, as.integer(n),
as.numeric(a), as.numeric(b), as.numeric(mean), as.numeric(sd))
}

etruncnorm <- function(a=-Inf, b=Inf, mean=0, sd=1)
.Call(C_do_etruncnorm,
as.numeric(a), as.numeric(b), as.numeric(mean), as.numeric(sd))

vtruncnorm <- function(a=-Inf, b=Inf, mean=0, sd=1)
.Call(C_do_vtruncnorm,
as.numeric(a), as.numeric(b), as.numeric(mean), as.numeric(sd))
```

Try the truncnorm package in your browser

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

truncnorm documentation built on March 31, 2023, 7:20 p.m.