How does one convert a Z-score from the Z-distribution (standard normal distribution, Gaussian distribution) to a p-value? I have yet to find the magical function in Scipy\'
For Scipy lovers, Tough this is old question but relevant, and we can have not only normal but other distributions as well so here is solution for few more distributions:
def get_p_value_normal(z_score: float) -> float:
"""get p value for normal(Gaussian) distribution
Args:
z_score (float): z score
Returns:
float: p value
"""
return round(norm.sf(z_score), decimal_limit)
def get_p_value_t(z_score: float) -> float:
"""get p value for t distribution
Args:
z_score (float): z score
Returns:
float: p value
"""
return round(t.sf(z_score), decimal_limit)
def get_p_value_chi2(z_score: float) -> float:
"""get p value for chi2 distribution
Args:
z_score (float): z score
Returns:
float: p value
"""
return round(chi2.ppf(z_score, df), decimal_limit)