Last active
September 1, 2017 03:50
-
-
Save jarhill0/c4845fff57b8e1fd0c07f0bf950bfac2 to your computer and use it in GitHub Desktop.
For use as a z-score table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt, erf, erfc | |
from scipy.special import erfinv, erfcinv | |
class Table: | |
def __init__(self, precision=4): | |
self.precision = precision | |
def below(self, z_score): | |
return round(0.5 + 0.5 * erf(z_score / sqrt(2)), self.precision) | |
def above(self, z_score): | |
return round(0.5 * erfc(z_score / sqrt(2)), self.precision) | |
def lower_percentage(self, percentage): | |
return round(sqrt(2) * erfinv((percentage - 0.5) / 0.5), self.precision) | |
def upper_percentage(self, percentage): | |
return round(sqrt(2) * erfcinv(percentage / 0.5), self.precision) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment