TorchLean API

NN.Proofs.Probability.NormalCdf

The standard normal distribution function #

PyTorch defines the exact GELU as x Φ(x), where Φ is the distribution function of the standard normal law, and computes Φ(x) as (1 + erf (x / √2)) / 2. This module proves that formula for Mathlib's ProbabilityTheory.cdf (gaussianReal 0 1) and Spec.erf: the derivative of the right side is the standard normal density, and both sides vanish at -∞. The exact real meaning of gelu(approximate=none) is therefore x Φ(x) with the measure-theoretic Φ.

References #

theorem Spec.hasDerivAt_normalCdf (x : ℝ) :
HasDerivAt (fun (t : ℝ) => (1 + erf (t / √2)) / 2) (ProbabilityTheory.gaussianPDFReal 0 1 x) x

The derivative of (1 + erf (x / √2)) / 2 is the standard normal density.

The distribution function of the standard normal law is (1 + erf (x / √2)) / 2.

Over the reals, the exact GELU is x Φ(x) for the standard normal distribution function Φ.