import sys if len(sys.argv) < 2: sys.exit('Usage: %s Z-score' % sys.argv[0]) z=float(sys.argv[1]) def z_to_p(z,output="F"): from math import erf,sqrt p=0.5*(1+erf(z/sqrt(2))) if output=="T": print "###########################################" print "# Convert Z score to p-value #" print "###########################################" print " Z= "+str(z) print " Left-tailed p-value P(z<Z)= "+str(p) print "Right-tailed p-value P(z>Z)= "+str(1-p) print "Two tailed p-value P(|z|>Z)= "+str(2*(1-p)) print "" else: return 2*(1-p) def main(z=z): z_to_p(z,output="T") if __name__=='__main__': main()