etn: Truncated Normal Distribution Expectation

Description Usage Arguments Details Value Author(s) Examples

View source: R/etn.R

Description

Calculate expectation of Truncated Normal distributions

Usage

1
2
etn(.mean = rep(0, 1), .sd = rep(1, length(.mean)), .low = rep(-Inf,
  length(.mean)), .high = rep(Inf, length(.mean)), .checks = TRUE)

Arguments

.mean

Length K vector with the means of the K Normal distributions prior to truncation

.sd

Length K vector with the standard deviations of the K Normal distributions prior to truncation

.low

Length K vector with the lower truncation bound of the K Normal distributions prior to truncation

.high

Length K vector with the upper truncation bound of the K Normal distributions prior to truncation

.checks

Length 1 logical vector indicating whether to perform checks (safer) or not (faster) on the input parameters

Details

The special values of -Inf and Inf are valid values in the .low and .high arguments, respectively.

Value

A length K vector of expectations corresponding to the Truncated Normal distributions. NAs are returned (with a warning) for invalid parameter values.

Author(s)

Jonathan Olmsted

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
etn() ## 0
etn(0, 1, -Inf, Inf) ## 0
etn(0, 1, -9999, 9999) ## 0

etn(0, 1, 0, Inf) ## 0.798

etn(0, 1, Inf, -Inf) ## NA with warning

etn(c(0, 0),
    c(1, 1),
    c(-Inf, 5),
    c(1, Inf)
    ) ## multiple expectations

RcppTN documentation built on May 2, 2019, 8:54 a.m.

Related to etn in RcppTN...