What's new
Math.stdNormPDF — the standard normal probability density φ(x), in 18-decimal fixed-point.
| Function | Gas | Max abs. error |
|---|---|---|
stdNormPDF |
320 | 3.0e-16 |
- 2.4× cheaper than the next on-chain implementation (SolStat, 761 gas), and about half the cost of its own integral
stdNormCDF(618 gas). - Accepts the full
int256domain and never reverts. Exactly even —φ(−x) = φ(x)to the wei — and saturates to0for|x| ≥ 9.1, where the density has already fallen below one wei.
import "defimath-lib/contracts/math/Math.sol";
int256 x = 1e18; // one standard deviation
uint256 y = Math.stdNormPDF(x); // y ≈ 0.24197072e18