def p_value(beta_hat_j: float, sigma_hat_j: float) -> float: if beta_hat_j > 0: #if the coefficient is positive, we need to compute #twice the probability of seeing an even larger value""" return 2 * (1 - normal_cdf(beta_hat_j / sigma_hat_j)) #"""Otherwise twice the probability of a smaller value""" else: return 2 * (normal_cdf(beta_hat_j / sigma_hat_j))
def normal_probability_between(lo: float, hi: float, mu: float = 0, sigma: float = 1) -> float: """The probability that an N(mu, sigma) is between lo and hi.""" return normal_cdf(hi, mu, sigma) - normal_cdf(lo, mu, sigma)
def normal_probability_above(lo: float, mu: float = 0, sigma: float = 1) -> float: """The probability that an N(mu, sigma) is greater than lo.""" return 1 - normal_cdf(lo, mu, sigma)
def normal_probability_between(lo, hi, mu=0, sigma=1): return normal_cdf(hi, mu, sigma) - normal_cdf(lo, mu, sigma)
def normal_probability_above(lo, mu=0, sigma=1): return 1 - normal_cdf(lo, mu, sigma)