Convert between Z and p values
Quite often I find I have to look up the conversion of a standard score (Z value) to a P value.
Some commonly encountered standard scores and their corresponding p-values, assuming one-tailed tests/hypothesis are:
Standard score (Z) | P-value |
---|---|
0.8416 | 0.2 |
1.2816 | 0.1 |
1.6449 | 0.05 |
1.96 | 0.025 |
2.0537 | 0.02 |
2.3263 | 0.01 |
3.0902 | 0.001 |
3.2905 | 0.0005 |
But what if we want a different value? Below is python code to generate your own custom value
from scipy import stats
# From Z-score to p-value
print(stats.norm.sf(2.3263))
# From p-value to Z-score
print(stats.norm.ppf(.99))
Verify the code here right in your browser! Just remember to hit shift + enter to evaluate code