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. """ z_critical2 = StatTool.z_critical_value(self.alpha, StatTool.TWO_TAILED_TEST) return z_critical2 * self.SEM()
def critical(self): """Z-critical value for the specified alpha and direction""" return StatTool.z_critical_value(self.alpha, self.dir)