Learn R Programming

lame (version 1.3.4)

log_phi_diff: Numerically stable log(Phi(hi) - Phi(lo))

Description

Computes log of the standard-normal CDF difference. Naive log(pnorm(hi) - pnorm(lo)) returns -Inf whenever both arguments are above ~7 or below ~-7 (catastrophic cancellation). Uses pnorm(., log.p = TRUE) and a stable log-subtraction.

Usage

log_phi_diff(hi, lo)

Value

numeric, log(Phi(hi) - Phi(lo))

Arguments

hi

numeric, upper bound

lo

numeric, lower bound (must be <= hi elementwise)