Statistics for Data Science - 2
Week 12 Notes
t-test, χ2 -test, two samples z/F -test
1. Normal samples and statistics: Consider the samples X1 , . . . , Xn ∼ iid Normal(µ, σ 2 ).
X1 + . . . + Xn
The sample mean, X =
n
2 1
The sample variance, S = [(X1 − X)2 + . . . + (Xn − X)2 ]
n−1
E[X] = µ, E[S 2 ] = σ 2
• X ∼ Normal(µ, σ 2 /n)
(n − 1) 2
• 2
S ∼ χ2n−1 , chi-squared distribution with n − 1 degrees of freedom.
σ
X −µ
• √ ∼ tn−1 , t-distribution with n − 1 degrees of freedom.
S/ n
2. t-test for mean (Variance unknown)
Consider the samples X1 , . . . , Xn ∼ iid Normal(µ, σ 2 ), σ 2 unknown. Following are the
three different possibilities:
• The null and alternative hypothesis are:
H0 : µ = µ0
HA : µ > µ0
Test Statistic: T = X
Test: Reject H0 , if T > c
X −µ
Given H0 , √ ∼ tn−1
S/ n
α =P (reject H0 | H0 is true)
=P (T > c | µ = µ0 )
c − µ0 c − µ0
=P tn−1 > √ = 1 − Ftn−1 √
s/ n s/ n
s
=⇒ c = √ Ft−1 (1 − α) + µ0
n n−1
Note: Ftn−1 is the CDF of t-distribution with n − 1 degrees of freedom.
• The null and alternative hypothesis are:
H0 : µ = µ0
HA : µ < µ0
Test Statistic: T = X
Test: Reject H0 , if T < c
X −µ
Given H0 , √ ∼ tn−1
S/ n
α =P (reject H0 | H0 is true)
=P (T < c | µ = µ0 )
c − µ0 c − µ0
=P tn−1 < √ = Ftn−1 √
s/ n s/ n
s
=⇒ c = √ Ft−1 (α) + µ0
n n−1
Note: Ftn−1 is the CDF of t-distribution with n − 1 degrees of freedom.
• The null and alternative hypothesis are:
H0 : µ = µ0
HA : µ ̸= µ0
Test Statistic: T = X − µ
Test: Reject H0 , if | X − µ |> c
X −µ
Given H0 , √ ∼ tn−1
S/ n
α =P (reject H0 | H0 is true)
=P (| X − µ |> c | µ = µ0 )
c −c
=P | tn−1 |> √ = 2Ftn−1 √
s/ n s/ n
−s
=⇒ c = √ Ft−1 (α/2)
n n−1
Note: Ftn−1 is the CDF of t-distribution with n − 1 degrees of freedom.
3. χ2 -test for variance
Consider the samples X1 , . . . , Xn ∼ iid Normal(µ, σ 2 ), σ 2 unknown. Following are the
three different possibilities:
• The null and alternative hypothesis are:
H0 : σ = σ0
HA : σ > σ0
Page 2
Test Statistic: S 2
Test: Reject H0 , if S 2 > c2
(n − 1) 2
Given H0 , S ∼ χ2n−1
σ2
α =P (reject H0 | H0 is true)
=P (S 2 > c2 | σ = σ0 )
2 (n − 1) 2 (n − 1) 2
=P χn−1 > c = 1 − Fχ2n−1 c
σ02 σ02
Note: Fχ2n−1 is the CDF of chi-distribution with n − 1 degrees of freedom.
• The null and alternative hypothesis are:
H0 : σ = σ0
HA : σ < σ0
Test Statistic: S 2
Test: Reject H0 , if S 2 < c2
(n − 1) 2
Given H0 , 2
S ∼ χ2n−1
σ
α =P (reject H0 | H0 is true)
=P (S 2 < c2 | σ = σ0 )
2 (n − 1) 2 (n − 1) 2
=P χn−1 < c = Fχ2n−1 c
σ02 σ02
Note: Fχ2n−1 is the CDF of chi-distribution with n − 1 degrees of freedom.
• The null and alternative hypothesis are:
H0 : σ = σ0
HA : σ ̸= σ0
Test Statistic: S 2
Test: Reject H0 , if S 2 < c2 or S 2 > c2
(n − 1) 2
Given H0 , S ∼ χ2n−1
σ2
α
=P (S 2 < c2 | H0 ) = P (S 2 > c2 | H0 )
2
Note: Fχ2n−1 is the CDF of chi-distribution with n − 1 degrees of freedom.
4. Two samples z-test (known variances)
Let X1 , . . . , Xn1 ∼ iid Normal(µ1 , σ12 )
and Y1 , . . . , Yn2 ∼ iid Normal(µ2 , σ22 )
Following are the three different possibilities:
Page 3
• The null and alternative hypothesis are:
H0 : µ1 = µ2
HA : µ1 ̸= µ2
Test Statistic: T = X − Y
Test: Reject H0 , if | T |> c
σ12 σ22
Given H0 , T ∼ Normal(0, σT2 ), where σT2 = +
n1 n2
α =P (reject H0 | H0 is true)
=P (| T |> c | µ1 = µ2 )
−c
=2FZ
σT
• The null and alternative hypothesis are:
H0 : µ1 = µ2
HA : µ1 > µ2
Test Statistic: T = X − Y
Test: Reject H0 , if X − Y > c
σ12 σ22
Given H0 , T ∼ Normal(0, σT2 ), where σT2 = +
n1 n2
α =P (reject H0 | H0 is true)
=P (X − Y > c | µ1 = µ2 )
c
=1 − FZ
σT
• The null and alternative hypothesis are:
H0 : µ1 = µ2
HA : µ1 < µ2
Test Statistic: T = X − Y
Test: Reject H0 , if Y − X > c
σ12 σ22
Given H0 , T ∼ Normal(0, σT2 ), where σT2 = +
n1 n2
α =P (reject H0 | H0 is true)
=P (Y − X > c | µ1 = µ2 )
c
=1 − FZ
σT
Page 4
5. Two samples F -test (known variances)
Let X1 , . . . , Xn1 ∼ iid Normal(µ1 , σ12 )
and Y1 , . . . , Yn2 ∼ iid Normal(µ2 , σ22 )
Following are the three different possibilities:
• The null and alternative hypothesis are:
H0 : σ1 = σ2
HA : σ1 > σ2
S12
Test Statistic: T =
S22
Test: Reject H0 , if T > 1 + c
Given H0 , T ∼ F (n1 − 1, n2 − 1)
α =P (reject H0 | H0 is true)
=P (T > 1 + c | σ1 = σ2 )
=1 − FF (n1 −1,n2 −1) (1 + c)
• The null and alternative hypothesis are:
H0 : σ1 = σ2
HA : σ1 < σ2
S12
Test Statistic: T =
S22
Test: Reject H0 , if T < 1 − c
Given H0 , T ∼ F (n1 − 1, n2 − 1)
α =P (reject H0 | H0 is true)
=P (T < 1 − c | σ1 = σ2 )
=FF (n1 −1,n2 −1) (1 − c)
• The null and alternative hypothesis are:
H0 : σ1 = σ2
HA : σ1 ̸= σ2
S12
Test Statistic: T =
S22
Test: Reject H0 , if T > 1 + cR or T < 1 − cL
Given H0 , T ∼ F (n1 − 1, n2 − 1)
α
=P (T > 1 + cR | H0 ) = P (T < 1 − cL | H0 )
2
Page 5