10 Constructing t interval for difference of means#

import numpy as np
import pandas as pd
from pandas import Series, DataFrame
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats, special

khanacademy

Constructing t interval for difference of means fig 1

\[\begin{split}\begin{array}{llllllll} \displaystyle z&=&\frac{\bar{x}-\mu}{\frac{\sigma}{n}} && t_{n-1}&=&\frac{\bar{x}-\mu}{\frac{s}{n}}\\ \displaystyle z&=&\frac{(\bar{x}_1-\bar{x}_2)-(\mu_1-\mu_2)}{\sigma\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}} && t_{n_1+n_2-2}&=&\frac{(\bar{x}_1-\bar{x}_2)-(\mu_1-\mu_2)}{s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}} && s_p^2=\frac{(n_1-1)s_1^2+(n_2-1)s_2^2}{n_1+n_2-2}\\ \displaystyle z&=&\frac{(\bar{x}_1-\bar{x}_2)-(\mu_1-\mu_2)}{\sqrt{\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2}}} && t_{\nu}&=&\frac{(\bar{x}_1-\bar{x}_2)-(\mu_1-\mu_2)}{\sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}} && \nu=\left[\frac{(s_1^2/n_1+s_2^2/n_2)^2}{\frac{(s_1^2/n_1)^2}{n_1-1}+\frac{(s_2^2/n_2)^2}{n_2-1}}\right]\\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{llllllll} \displaystyle \bar{x}\pm z_*\frac{\sigma}{n} && \bar{x}\pm t_*\frac{s}{n}\\ \displaystyle (\bar{x}_1-\bar{x}_2)\pm z_*\sigma\sqrt{\frac{1}{n_1}+\frac{1}{n_2}} && (\bar{x}_1-\bar{x}_2)\pm t_*s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}\\ \displaystyle (\bar{x}_1-\bar{x}_2)\pm z_*\sqrt{\frac{\sigma_1^2}{n_1}+\frac{\sigma_2^2}{n_2}} && (\bar{x}_1-\bar{x}_2)\pm t_*\sqrt{\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}}\\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{lll} H_0:\ \mu=\mu_0,&&H_1:\ \mu\neq \mu_0\\ H_0:\ \mu=\mu_0,&&H_1:\ \mu> \mu_0\\ H_0:\ \mu=\mu_0,&&H_1:\ \mu< \mu_0\\ \\ H_0:\ \mu_1=\mu_2,&&H_1:\ \mu_1\neq \mu_2\\ H_0:\ \mu_1=\mu_2,&&H_1:\ \mu_1> \mu_2\\ H_0:\ \mu_1=\mu_2,&&H_1:\ \mu_1< \mu_2\\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{lll} H_0:\ p=p_0,&&H_1:\ p\neq p_0\\ H_0:\ p=p_0,&&H_1:\ p> p_0\\ H_0:\ p=p_0,&&H_1:\ p< p_0\\ \\ H_0:\ p_1=p_2,&&H_1:\ p_1\neq p_2\\ H_0:\ p_1=p_2,&&H_1:\ p_1> p_2\\ H_0:\ p_1=p_2,&&H_1:\ p_1< p_2\\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{lll} H_0:\ \mu=\mu_0,&&H_1:\ \mu\neq \mu_0\\ H_0:\ \mu=\mu_0,&&H_1:\ \mu> \mu_0\\ H_0:\ \mu=\mu_0,&&H_1:\ \mu< \mu_0\\ \\ H_0:\ \mu_d=0,&&H_1:\ \mu_d\neq 0\\ H_0:\ \mu_d=0,&&H_1:\ \mu_d>0\\ H_0:\ \mu_d=0,&&H_1:\ \mu_d<0\\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{llllllll} \displaystyle z&=&\frac{\bar{x}-\mu}{\frac{\sigma}{n}} && t_{n-1}&=&\frac{\bar{x}-\mu}{\frac{s}{n}}\\ \displaystyle z&=&\frac{\bar{d}-\mu_d}{\frac{\sigma_d}{n}} && t_{n-1}&=&\frac{\bar{d}-\mu_d}{\frac{s_d}{n}}\\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{llllllll} \displaystyle \bar{x}\pm z_*\frac{\sigma}{n} && \bar{x}\pm t_*\frac{s}{n}\\ \displaystyle \bar{d}\pm z_*\frac{\sigma_d}{n} && \bar{d}\pm t_*\frac{s_d}{n}\\ \end{array}\end{split}\]
\[\begin{split}\begin{array}{lll} H_0:\ p_1=p_2,&&H_1:\ p_1\neq p_2\\ H_0:\ p_1=p_2,&&H_1:\ p_1> p_2\\ H_0:\ p_1=p_2,&&H_1:\ p_1< p_2\\ \\ H_0:\ \mu_1=\mu_2,&&H_1:\ \mu_1\neq \mu_2\\ H_0:\ \mu_1=\mu_2,&&H_1:\ \mu_1> \mu_2\\ H_0:\ \mu_1=\mu_2,&&H_1:\ \mu_1< \mu_2\\ \\ H_0:\ \mu_d=0,&&H_1:\ \mu_d\neq 0\\ H_0:\ \mu_d=0,&&H_1:\ \mu_d>0\\ H_0:\ \mu_d=0,&&H_1:\ \mu_d<0\\ \end{array}\end{split}\]