Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

C2 Foundation Mathematics

Lecture 7 Part2
The T-test

INTO City University London


Z-test example
Question: A lightbulb company says their lightbulbs last a mean
time of 1000 hours with a standard deviation of 50 hours.
We think their lightbulbs last longer than this and propose a test at
a 5% level of signicance.
We buy and test a sample 75 lightbulbs and they last a mean time
of 1022 hours.

Answer:
I Hypotheses: H0 : µ = 1000, H1 : µ > 1000
I Critical value: +1.65

I Test statistic: σ
x̄−A 1022−1000
= 3.81 to 2 d.p.
/ n =
√ √
50/ 75

I Decision: 3.81 > 1.65 so reject H0

I Conclusion: The sample provides sucient evidence at 5%


signicance level to reject null hypothesis; the lightbulbs last
longer than 1000 hours.
T-test example

Question: A lightbulb company says their lightbulbs last a mean


time of 1000 hours.
We think their lightbulbs last longer than this and propose a test at
a 5% level of signicance.
We buy and test a sample of 10 light bulbs. Their lifetimes in hours
are listed below.
1020, 860, 987, 1109, 1015, 952, 964, 1007, 1082, 1017
T-test summary

I You will be given


1. Population mean, A
2. Signicance level (1% or 5%)
3. Sample data set
4. Quantifying word.
I You have to work out
1. Null hypothesis (H0 : µ = A) and alternative hypotheis
2. Degrees of freedom, d.o.f. = n − 1
3. Critical value(s), look this up in the table
4. Sample mean, x̄ = Σx n q
P 2 2
5. Sample standard deviation, s = x −nx̄
n−1 (to 3 d.p.)
(MAKE SURE YOU CALCULATE s, not σ )
6. Test statistic, x̄−A
s/√n (to 2 d.p.)

7. Decision, accept/reject H0 (sketch a picture - it helps)


8. Conclusion, write this in words
The dierence between a Z-test and a T-test

In a Z-test the sample is large (n ≥ 25). You are given the sample
mean and population or sample standard deviation
The dierence between a Z-test and a T-test

In a Z-test the sample is large (n ≥ 25). You are given the sample
mean and population or sample standard deviation

In a T-test the sample is small (n < 25). You usually have to work
out the sample mean and the sample standard deviation. Also in a
T-test you have to work out the degrees of freedom to use in the
critical value table.
The null hypothesis and the alternative hypothesis for the
Z-test and T-test

I The null hypothesis is initially assumed to be true. It is


H0 : µ = A

where µ is 'population mean' and A is the hypothetical value


of the population mean
The null hypothesis and the alternative hypothesis for the
Z-test and T-test

I The null hypothesis is initially assumed to be true. It is


H0 : µ = A

where µ is 'population mean' and A is the hypothetical value


of the population mean
I The alternative hypothesis is either
H1 : µ 6= A or H1 : µ < A or H1 : µ > A
H1 : µ 6= A

If our alternative hypothesis is H1 : µ 6= A we are doing a two-tailed


test and we have 2 critical values, one negative and one positive.
The critical value is the boundary of the rejection region.
We have the following picture:

-critical value +critical value

The rejection (shaded) regions have a combined area of 5% or 1%


of the total area under the curve.
H1 : µ > A

If our alternative hypothesis is H1 : µ > A we are doing a


one-tailed test and we have 1 critical value which is positive.
The critical value is the boundary of the rejection region.
We have the following picture:

critical value

The rejection region has an area of 5% or 1% of the total area


under the curve.
H1 : µ < A

If our alternative hypothesis is H1 : µ < A we are doing a


one-tailed test and we have 1 critical value which is negative.
The critical value is the boundary of the rejection region.
We have the following picture:

-critical value

The rejection region has an area of 5% or 1% of the total area


under the curve.
Critical value (T-test)
The critical value is the boundary (or boundaries) of the rejection
region(s). In a T-test this depends on the alternative hypothesis,
signicance level and degrees of freedom (d.o.f. = n − 1, where n
is the number of values in the data set)
5% signicance level 1% signicance level
d.o.f. One-tailed Two-tailed One-tailed Two-tailed
2 2.92 4.30 6.97 9.93
3 2.35 3.18 4.54 5.84
4 2.13 2.78 3.75 4.60
5 2.02 2.57 3.37 4.03
6 1.94 2.45 3.14 3.71
7 1.90 2.37 3.00 3.50
8 1.86 2.31 2.90 3.36
9 1.83 2.26 2.82 3.25
10 1.81 2.23 2.76 3.17
Degrees of freedom (T-test)
I The degrees of freedom of a set of data is a way of measuring
how the tests eect each other.
I If the data has size n and each sample does not eect any
others the degree of freedom is n − 1. (This is usually the case
with our data).
I Consider a bag containing 10 stones.
I If as a sample we pick out 10 stones our degree of freedom is 0
because the choice of the rst one constrains the possibilities
for all others and the nal one is left with no choices.
I If as a sample we pick out 7 stones our degree of freedom is 3
because if we take out three stones before we start the choice
of stones is unique.
I If as a sample we just pick out 1 stone our degree of freedom
is 9.
Sample variance, s2 , and sample standard deviation, s

I The sample standard deviation, s of a set of data is slightly


dierent from the standard deviation σ . It is important to use
the correct formula.

I Recall that standard deviation = variance,
so rst calculate the sample variance, then take the square root
of the sample variance to get the sample stadard deviation.
I For a T-test question ALWAYS use the sample variance
formula P 2 2
x − nx̄
s2 =
n−1
I (For a T-test question DO NOT USE the variance formula
from the Basic Statistics Lecture)
I (We are using the sample data to work out an approximation
to the population standard deviation)
Test statistic
I The T-test statistic is
x̄ − A
s/√n
Test statistic
I The T-test statistic is
x̄ − A
s/√n

I The test statistic is dierence between the sample mean, x̄


and the (hypothetical) population mean A, divided by the
standard error.
I The standard error is σ/√n for the Z -test and s/√n for the
T -test, where n is the sample size, σ is the population
standard deviation and s is the sample standard deviation.
Test statistic
I The T-test statistic is
x̄ − A
s/√n

I The test statistic is dierence between the sample mean, x̄


and the (hypothetical) population mean A, divided by the
standard error.
I The standard error is σ/√n for the Z -test and s/√n for the
T -test, where n is the sample size, σ is the population
standard deviation and s is the sample standard deviation.

I If the sample mean is much larger than the population mean,


then the test statistic is large and positive.
I If the sample mean is much smaller than the population mean,
then the test statistic is large and negative.
I If the sample mean is exactly the same as the population
mean, then the test statistic is ZERO!
The decision and conclusion
I The DECISION is either accept or reject H0 , with justication
(sketch a picture - it helps)
I For example: 3.81>1.65 so reject H0 .
The decision and conclusion
I The DECISION is either accept or reject H0 , with justication
(sketch a picture - it helps)
I For example: 3.81>1.65 so reject H0 .
I The CONCLUSION is a written explanation.
I For example: The lightbulbs last longer than 1000 hours. (The
sample provides sucient evidence to reject the null
hypothesis at a 5% signicance level .)

I If the test statistic lies beyond the critical value(s) (in the
rejection region) we reject H0 . THE SAMPLE PROVIDES
SUFFICIENT EVIDENCE TO REJECT H0 at the specied
signicance level.
I If the test statistic does not lie beyond the critical value, we
accept H0 . THE SAMPLE DOES NOT PROVIDE
SUFFICIENT EVIDENCE TO REJECT H0 at the specied
signicance level.
Type I and Type II errors

I A Type I error occurs when you reject H0 , but actually H0 is


true.
Type I and Type II errors

I A Type I error occurs when you reject H0 , but actually H0 is


true.
I A Type II error occurs when you accept H0 , but actually H0 is
false.
Type I and Type II errors

I A Type I error occurs when you reject H0 , but actually H0 is


true.
I A Type II error occurs when you accept H0 , but actually H0 is
false.
H0 true H0 false
Accept H0 Type II error
Reject H0 Type I error
Type I and Type II errors

I A Type I error occurs when you reject H0 , but actually H0 is


true.
I A Type II error occurs when you accept H0 , but actually H0 is
false.
H0 true H0 false
Accept H0 Type II error
Reject H0 Type I error

I Suppose H0 is the hypothesis that a man is innocent.


Evidence is used to try to prove that H0 is incorrect. Making a
Type I error is equivalent to wrongly convicting an innocent
man, and making a Type II error is equivalent to letting a
guilty man go free.
Normal distribution X ∼ N (µ, σ 2 ) and the theory behind
the Z-test and the T-test
If samples of size n are taken from a population with mean A and
standard deviation σ , then the sample means are distributed
normally, with mean A and standard deviation σ/√n.
0.5

0.4

0.3

y 0.2

0.1

x
−4 −2 2 4

When we calculate the test statistic, we are calculating the Z-score


of the sample mean. The critical value is the Z-score of a sample
mean which we have a 5% (or 1%) probability of obtaining. For
further information, try a statistics book from the library, or the
khanacademy videos on youtube.
T-test - example 1
A light bulb company claim their light bulbs last an average of
1000 hours. We want to test whether this is true to a 5% level of
signicance.
T-test - example 1
A light bulb company claim their light bulbs last an average of
1000 hours. We want to test whether this is true to a 5% level of
signicance.
I H0 : µ = 1000.
H1 : µ 6= 1000.
We test a sample of 10 light bulbs. Their lifetimes in hours are
listed below.
1020, 860, 987, 1109, 1015, 952, 964, 1007, 1082, 1017
T-test - example 1
A light bulb company claim their light bulbs last an average of
1000 hours. We want to test whether this is true to a 5% level of
signicance.
I H0 : µ = 1000.
H1 : µ 6= 1000.
We test a sample of 10 light bulbs. Their lifetimes in hours are
listed below.
1020, 860, 987, 1109, 1015, 952, 964, 1007, 1082, 1017

I Degrees of freedom:(d.o.f. = n − 1) 10-1=9


T-test - example 1
A light bulb company claim their light bulbs last an average of
1000 hours. We want to test whether this is true to a 5% level of
signicance.
I H0 : µ = 1000.
H1 : µ 6= 1000.
We test a sample of 10 light bulbs. Their lifetimes in hours are
listed below.
1020, 860, 987, 1109, 1015, 952, 964, 1007, 1082, 1017

I Degrees of freedom:(d.o.f. = n − 1) 10-1=9


I Critical values: We are doing a two-tailed test as our
alternative hypothesis says µ 6= 1000. Look up 5% with 9
degrees of freedom for the critical value.
T-test - example 1
A light bulb company claim their light bulbs last an average of
1000 hours. We want to test whether this is true to a 5% level of
signicance.
I H0 : µ = 1000.
H1 : µ 6= 1000.
We test a sample of 10 light bulbs. Their lifetimes in hours are
listed below.
1020, 860, 987, 1109, 1015, 952, 964, 1007, 1082, 1017

I Degrees of freedom:(d.o.f. = n − 1) 10-1=9


I Critical values: We are doing a two-tailed test as our
alternative hypothesis says µ 6= 1000. Look up 5% with 9
degrees of freedom for the critical value.
I Our critical values are -2.26 and 2.26.
T-test - example 1
A light bulb company claim their light bulbs last an average of
1000 hours. We want to test whether this is true to a 5% level of
signicance.
I H0 : µ = 1000.
H1 : µ 6= 1000.
We test a sample of 10 light bulbs. Their lifetimes in hours are
listed below.
1020, 860, 987, 1109, 1015, 952, 964, 1007, 1082, 1017

I Degrees of freedom:(d.o.f. = n − 1) 10-1=9


I Critical values: We are doing a two-tailed test as our
alternative hypothesis says µ 6= 1000. Look up 5% with 9
degrees of freedom for the critical value.
I Our critical values are -2.26 and 2.26.
T-test - example 1
I Sample mean: x̄ = 1001.3
T-test - example 1
I Sample mean: x̄ = 1001.3
I Sample variance:
x2 − nx̄2
P
2
s = = 4768.9
n−1
I Sample standard deviation:

s= 4768.9 = 69.057 to 3 d.p.
I Test statistic:
x̄ − A 1001.3 − 1000
s/√n
= 69.057 √ = 0.06 to 2 d.p.
/ 10
T-test - example 1
I Sample mean: x̄ = 1001.3
I Sample variance:
x2 − nx̄2
P
2
s = = 4768.9
n−1
I Sample standard deviation:

s= 4768.9 = 69.057 to 3 d.p.
I Test statistic:
x̄ − A 1001.3 − 1000
s/√n
= 69.057 √ = 0.06 to 2 d.p.
/ 10

I Decision: −2.26 < 0.06 < 2.26 .The test statistic is not in the
rejection region so we accept the null hypothesis.
I Conclusion: The average bulb lifetime is 1000 hours. (The
sample of 10 light bulbs does not provide sucient evidence at
a 5% signicance level to reject the light bulb company's
claim.)
T-test - example 2
An average person is said to be able run to 100m in 14.2 seconds.
We think that this is a bit on the slow side. We decide to test at a
5% level of signicance.
T-test - example 2
An average person is said to be able run to 100m in 14.2 seconds.
We think that this is a bit on the slow side. We decide to test at a
5% level of signicance.
I H0 : µ = 14.2
H1 : µ < 14.2.
We ask 7 people to run 100m. Their times are as follows:
12.6, 13.2, 11.7, 14.6, 11.3, 12.0, 13.5

I The degree of freedom of this set is 7-1=6


T-test - example 2
An average person is said to be able run to 100m in 14.2 seconds.
We think that this is a bit on the slow side. We decide to test at a
5% level of signicance.
I H0 : µ = 14.2
H1 : µ < 14.2.
We ask 7 people to run 100m. Their times are as follows:
12.6, 13.2, 11.7, 14.6, 11.3, 12.0, 13.5

I The degree of freedom of this set is 7-1=6


I We are doing a one-tailed test as our alternative hypothesis
says µ < 14.2. Look up 5% with 6 degrees of freedom for the
critical value.
I The critical value is −1.94.
T-test - example 2
I Sample mean: x̄ = 12.7
T-test - example 2
I Sample mean: x̄ = 12.7
I Sample variance:
x2 − nx̄2
P
2
s = = 1.327
n−1
T-test - example 2
I Sample mean: x̄ = 12.7
I Sample variance:
x2 − nx̄2
P
2
s = = 1.327
n−1

I Sample standard deviation:



s= 1.327 = 1.152 to 3 d.p.
I Test statistic:
x̄ − A 12.7 − 14.2
T = s/√n
= 1.152 √ = −3.45 to 2 d.p.
/ 7
T-test - example 2
I Sample mean: x̄ = 12.7
I Sample variance:
x2 − nx̄2
P
2
s = = 1.327
n−1

I Sample standard deviation:



s= 1.327 = 1.152 to 3 d.p.
I Test statistic:
x̄ − A 12.7 − 14.2
T = s/√n
= 1.152 √ = −3.45 to 2 d.p.
/ 7
T-test - example 2
I Sample mean: x̄ = 12.7
I Sample variance:
x2 − nx̄2
P
2
s = = 1.327
n−1

I Sample standard deviation:



s= 1.327 = 1.152 to 3 d.p.
I Test statistic:
x̄ − A 12.7 − 14.2
T = s/√n
= 1.152 √ = −3.45 to 2 d.p.
/ 7

I Decision: −3.45 < −1.94 so we reject the null hypothesis.


I Conclusion: People run faster than 100m in 14.2s. (The data
collected provides sucient evidence at a 5% signicance level
to reject the hypothesis that the average person runs 100m in
14.2s.)
T-test - example 3

I An average person has an IQ of 100. We think that we are


cleverer than this so we test at a 1% level of signicance.
T-test - example 3

I An average person has an IQ of 100. We think that we are


cleverer than this so we test at a 1% level of signicance.
I H0 : µ = 100.
I H1 : µ > 100.
T-test - example 3

I An average person has an IQ of 100. We think that we are


cleverer than this so we test at a 1% level of signicance.
I H0 : µ = 100.
I H1 : µ > 100.
I We got 8 people to take an IQ test. Their marks were as
follows:
117, 106, 93, 142, 110, 114, 120, 126
T-test - example 3

I An average person has an IQ of 100. We think that we are


cleverer than this so we test at a 1% level of signicance.
I H0 : µ = 100.
I H1 : µ > 100.
I We got 8 people to take an IQ test. Their marks were as
follows:
117, 106, 93, 142, 110, 114, 120, 126
T-test - example 3

I An average person has an IQ of 100. We think that we are


cleverer than this so we test at a 1% level of signicance.
I H0 : µ = 100.
I H1 : µ > 100.
I We got 8 people to take an IQ test. Their marks were as
follows:
117, 106, 93, 142, 110, 114, 120, 126

I The degree of freedom of this set is 8-1=7


T-test - example 3

I An average person has an IQ of 100. We think that we are


cleverer than this so we test at a 1% level of signicance.
I H0 : µ = 100.
I H1 : µ > 100.
I We got 8 people to take an IQ test. Their marks were as
follows:
117, 106, 93, 142, 110, 114, 120, 126

I The degree of freedom of this set is 8-1=7


I We are doing a one-tailed test as our alternative hypothesis
says µ > 100. Look up 1% with 7 degrees of freedom for the
critical value.
I The critical value is 3.00.
T-test - example 3
I Sample mean: x̄ = 116
T-test - example 3
I Sample mean: x̄ = 116
I Sample variance:
x2 − nx̄2
P
2
s = = 208.857
n−1
T-test - example 3
I Sample mean: x̄ = 116
I Sample variance:
x2 − nx̄2
P
2
s = = 208.857
n−1

I Sample standard deviation:


s = 14.452 to 3 d.p.
I Test statistic
x̄ − A 116 − 100
s/√n
= 14.452 √ = 3.13 to 2 d.p.
/ 8
T-test - example 3
I Sample mean: x̄ = 116
I Sample variance:
x2 − nx̄2
P
2
s = = 208.857
n−1

I Sample standard deviation:


s = 14.452 to 3 d.p.
I Test statistic
x̄ − A 116 − 100
s/√n
= 14.452 √ = 3.13 to 2 d.p.
/ 8

I Decision: 3.00 < 3.13 so we reject the null hypothesis.


I Conclusion: The average IQ is more than100. (The sample of
8 people provides sucient evidence at a 1% signicance level
to reject the claim that the average IQ is100.)
T-test - example 4
I The chocolate company claims that a bag of malteasers has an
average of 20 malteasers inside. In the name of science we buy
6 bags to see if this is right to a 1% level of signicance. The
bags have the following number of malteasers:
19, 16, 18, 19, 22, 14
T-test - example 4
I The chocolate company claims that a bag of malteasers has an
average of 20 malteasers inside. In the name of science we buy
6 bags to see if this is right to a 1% level of signicance. The
bags have the following number of malteasers:
19, 16, 18, 19, 22, 14

I H0 : µ = 20.
I H1 : µ 6= 20.
T-test - example 4
I The chocolate company claims that a bag of malteasers has an
average of 20 malteasers inside. In the name of science we buy
6 bags to see if this is right to a 1% level of signicance. The
bags have the following number of malteasers:
19, 16, 18, 19, 22, 14

I H0 : µ = 20.
I H1 : µ 6= 20.
I Degree of freedom is 6-1=5.
T-test - example 4
I The chocolate company claims that a bag of malteasers has an
average of 20 malteasers inside. In the name of science we buy
6 bags to see if this is right to a 1% level of signicance. The
bags have the following number of malteasers:
19, 16, 18, 19, 22, 14

I H0 : µ = 20.
I H1 : µ 6= 20.
I Degree of freedom is 6-1=5.
I We are doing a two-tailed test as our alternative hypothesis
says µ 6= 20. Look up 1% with 5 degrees of freedom for the
critical values.
I The critical values are −4.03 and 4.03.
T-test - example 4
I Sample mean: x̄ = 18.
T-test - example 4
I Sample mean: x̄ = 18.
I Sample standard deviation:
x2 − nx̄2
P
2
s = = 7.6
n−1
T-test - example 4
I Sample mean: x̄ = 18.
I Sample standard deviation:
x2 − nx̄2
P
2
s = = 7.6
n−1

I Sample variance:
s = 2.757 to 3 d.p.
I Test statistic
x̄ − A 18 − 20
s/√n
= 2.757 √ = −1.78 to 2 d.p.
/ 6
T-test - example 4
I Sample mean: x̄ = 18.
I Sample standard deviation:
x2 − nx̄2
P
2
s = = 7.6
n−1

I Sample variance:
s = 2.757 to 3 d.p.
I Test statistic
x̄ − A 18 − 20
s/√n
= 2.757 √ = −1.78 to 2 d.p.
/ 6
T-test - example 4
I Sample mean: x̄ = 18.
I Sample standard deviation:
x2 − nx̄2
P
2
s = = 7.6
n−1

I Sample variance:
s = 2.757 to 3 d.p.
I Test statistic
x̄ − A 18 − 20
s/√n
= 2.757 √ = −1.78 to 2 d.p.
/ 6

I Decision: −4.03 < −1.78 < 4.03 so we accept the null


hypothesis.
I Conclusion: There is an average of 20 maltesers per bag. (The
sample of 6 bags of maltesers does not provide sucient
evidence at a 1% signicance level to reject the chocolate
company's claim.)

You might also like