Skip to content
fn

ndtr

→Tensor
ndtr(input: Tensor)

Standard normal cumulative distribution function.

Evaluates Φ(x)=P(Z≤x)\Phi(x) = P(Z \le x) where ZZ is a standard normal random variable. Implemented as a thin wrapper around the error function via the textbook identity Φ(x)=12 (1+erf(x/2))\Phi(x) = \tfrac{1}{2}\,(1 + \mathrm{erf}(x/\sqrt{2})).

Parameters

inputTensor
Input tensor; any floating-point dtype.

Returns

Tensor

Φ(x)\Phi(x) element-wise, same shape and dtype as input; values lie in (0, 1).

Notes

Definition:

Φ(x)=12π∫−∞xe−t2/2 dt=12(1+erf ⁣(x2)).\Phi(x) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^x e^{-t^2/2}\, dt = \frac{1}{2}\left(1 + \mathrm{erf}\!\left( \frac{x}{\sqrt{2}}\right)\right).

For x deep in the left tail, ndtr underflows to 0 and losses precision; prefer log_ndtr for log-domain work. Special values: Φ(−∞)=0\Phi(-\infty) = 0, Φ(0)=0.5\Phi(0) = 0.5, Φ(+∞)=1\Phi(+\infty) = 1.

Examples

>>> import lucid
>>> from lucid.special import ndtr
>>> ndtr(lucid.tensor([-3.0, -1.0, 0.0, 1.0, 3.0]))
tensor([0.00135, 0.1587, 0.5, 0.8413, 0.9987])