Skip to main content

log_ndtr_with_deriv_impl

Function log_ndtr_with_deriv_impl 

Source
pub fn log_ndtr_with_deriv_impl<P, E, V, const DERIV: bool>(x: V) -> (V, V)
where P: Policy, E: FloatElement, V: FloatVector<Element = E> + SpecializedSpecialMath<E>,
Expand description

(ln ndtr(x), phi(x)/ndtr(x)): the value and its derivative, the inverse Mills ratio.

The ratio costs one exp in the moderate and right arms (phi needs e^{-x^2/2}, which erfc keeps inside itself) and nothing in the tail, where it is 1/(sqrt(2 pi) a) from the erfcx already in hand. With DERIV = false the second element is zero and no extra work is done.

Last built: 2026-09-08 21:35:55 UTC