def calc_double_sided_student_t_probability(t, n): "Calculate the p-value using a double sided student t distribution" # integrate a finite area from the origin to t p_aux = simpson_rule_integrate(f_student_t_distribution(n), 0, t) # return the area of the two tails of the distribution (symmetrical) return (0.5 - p_aux) * 2
def calc_student_t_probability(x, n): "Integrate t distribution from -infinity to x with n degrees of freedom" inf = float("infinity") p = simpson_rule_integrate(f_student_t_distribution(n), -inf, x) return p