def margin_of_error(self): """Margin of error is the distance from μ (in either direction), expressed in the same unit as the original sample, where it is within the confidence interval (CI). Margin of error is half the width of the CI. For example, if μ is $50, and alpha is 5%, and Standard Error is $15. Then for 95% confidence, the confidence interval is between $50 - (1.96 * $15) and $50 + (1.96 * $15). In this case, (1.96 * $15) is the margin of error. """ # Margin of error always uses two tailed t_critical2 = StatTool.t_critical_value(self.alpha, StatTool.TWO_TAILED_TEST, self.df()) return t_critical2 * self.SEM()
def critical(self): """t-critical value for the specified confidence/alpha. Value may be negative!""" return StatTool.t_critical_value(self.alpha, self.dir, self.df())