Skip to content

๐Ÿ”Ž Highly optimized Solidity library of statistical functions rationally approximated

Notifications You must be signed in to change notification settings

cairoeth/solgauss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”Ž solgauss

CI

Highly optimized Solidity library for statistical functions rationally approximated with an error of less than 1 ร— 10โปโธ, including erfc, erfinv, erfcinv, ppf, and cdf.

โš™๏ธ Installation

To install with Foundry:

forge install cairoeth/solgauss

โ›ฝ Gas Benchmarks

To run the gas benchmark: forge t --gas-report --fuzz-seed 0x123

cdf

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

erfc

Function min avg median max
erfc (solgauss) 687 688 687 693
erfc (gud-cdf) 569 570 569 603
erfc (solstat) 4436 4453 4436 4543

erfcinv

Function min avg median max
erfcinv 669 828 783 1847

erfinv

Function min avg median max
erfinv 604 749 718 1796

ppf

Function min avg median max
ppf 2001 2001 2001 2001

โœ… Tests

Run the following for the dependencies used in the (differential) tests:

  1. python -m venv venv && source venv/bin/activate
  2. pip install mpmath

To run the tests: forge t

๐Ÿ‘‡ Acknowledgements

This repository is inspired by or directly modified from many sources, primarily:

About

๐Ÿ”Ž Highly optimized Solidity library of statistical functions rationally approximated

Resources

Stars

Watchers

Forks