Learn R Programming

lame (version 1.3.4)

rtnorm_interval_logp: Exact truncated-normal draw on (lb, ub) via the log.p-scale inverse CDF

Description

Draws z ~ N(ez, 1) truncated to (lb, ub) for each cell, working entirely on the log-probability scale in the tail that contains the truncation interval. This stays exact for arbitrarily extreme ez / bounds (log-scale pnorm/qnorm are accurate to |ez| of several hundred), so no probability clamp is needed. Infinite bounds reduce to the one-sided case automatically.

Usage

rtnorm_interval_logp(ez, lb, ub)

Value

vector of truncated-normal draws, same length as ez.

Arguments

ez

vector of conditional means.

lb

lower bounds (recycled to length(ez)).

ub

upper bounds (recycled to length(ez)).

Author

Cassy Dorff, Shahryar Minhas, Tosin Salau