Highly optimized Solidity library for statistical functions rationally approximated with an error of less than 1 ร 10โปโธ, including erfc
, erfinv
, erfcinv
, ppf
, and cdf
.
To install with Foundry:
forge install cairoeth/solgauss
To run the gas benchmark: forge t --gas-report --fuzz-seed 0x123
Function | min | avg | median | max |
---|---|---|---|---|
cdf (solgauss) | 519 | 610 | 519 | 833 |
cdf (solidity-cdf) | 492 | 617 | 492 | 914 |
cdf (gud-cdf) | 704 | 736 | 704 | 841 |
cdf (solstat) | 916 | 4258 | 5137 | 5137 |
Function | min | avg | median | max |
---|---|---|---|---|
erfc (solgauss) | 687 | 688 | 687 | 693 |
erfc (gud-cdf) | 569 | 570 | 569 | 603 |
erfc (solstat) | 4436 | 4453 | 4436 | 4543 |
Function | min | avg | median | max |
---|---|---|---|---|
erfcinv | 669 | 828 | 783 | 1847 |
Function | min | avg | median | max |
---|---|---|---|---|
erfinv | 604 | 749 | 718 | 1796 |
Function | min | avg | median | max |
---|---|---|---|---|
ppf | 2001 | 2001 | 2001 | 2001 |
Run the following for the dependencies used in the (differential) tests:
python -m venv venv && source venv/bin/activate
pip install mpmath
To run the tests: forge t
This repository is inspired by or directly modified from many sources, primarily:
- gud-cdf: codification script
- Rational Chebyshev Approximation Using Linear Equations