Interval of Confidence
Interval of Confidence
2022/2023
Luís Paquete
University of Coimbra
Confidence intervals
Outline
● Point estimation
● Confidence interval for the mean (large and small number of measurements)
● Confidence interval for the proportion
Confidence intervals
Confidence intervals
Point estimation
Point estimation
● The value of a point estimator over x1, x2, ..., xn is a point estimate of the population
parameter.
is a point estimate of , the mean grade average of all the students in the population.
Confidence intervals
● If each of the n measurements used to compute are independent and come from
the same population with mean and standard deviation , the Central Limit
Theorem ensures that for large n (typically, n ≥ 30), the sample mean follows a
normal distribution with mean = and standard deviation =
Confidence intervals
15000
Uniform distribution and collect the mean for each sample.
Print the mean and the standard deviation of the sample
10000
means and plot the histogram of the sample means.
Frequency
all = c()
5000
for (i in 1:100000) {
all = c(all,mean(runif(30)))
}
print(mean(all));print(sd(all))
0
print(0.5); print(1/sqrt(12)/sqrt(30))
0.3 0.4 0.5 0.6 0.7
hist(all)
all
● The mean is 0.5001 and the standard deviation is 0.05257 (it may differ slightly if you repeat).
Confidence intervals
● Which distribution?
Confidence intervals
● Since the number of measurements is large, the sample mean follows a normal
distribution with mean and standard deviation This is our reference
distribution (let's assume that is known).
margin margin
Confidence intervals
● We use the standard normal distribution (SND), which is a normal distribution with
mean 0 and standard deviation 1. The transformation from a normal distribution to
the SND is performed as follows:
- 0
Confidence intervals
( , )
Confidence intervals
● This leads to the following extreme points for the confidence interval:
Confidence intervals
● From a z-table
Confidence intervals
( , )
where is the value of the t distribution with n-1 degrees of freedom that
has an area of to its right.
● The t distribution for large n approximates the standard normal distribution quite well.
Confidence intervals
● From a t-table
Confidence intervals
Example
● Determine, on average, the time required to write a file of a particular size to a disk
drive. You collected the following values in seconds from 8 measurements: 8.0, 7.0,
5.0, 9.0, 9.5, 11.3, 5.2, and 8.5. Then, =7.94 and s = 2.14.
● Assume 90% confidence level ( =0.1). Since n=8, we use the t distribution with
seven degrees of freedom.
Example
● In R:
Example
● In R:
data: d
t = 10.468, df = 7, p-value = 1.581e-05
alternative hypothesis: true mean is not equal to 0
90 percent confidence interval:
6.500893 9.374107
sample estimates:
mean of x
7.9375
Confidence intervals
Example
● One may be interested on proportions, for instance, the fraction of the time each
event occurs.
● The proportion p can be estimated by the sample proportion where m is
the number of times the desired outcome occurs out of n measurements.
Confidence intervals
● The distribution of the sample proportion of size n has mean np/n = p and
standard deviation .
( , )
Confidence intervals
Example
● Determine how much time the processor spends executing the operating system
compared with how much time it spends executing the users' applications programs.
● A counter, n, is incremented every time the interrupt-service routine is executed and
counts how many times the interrupt occurs. A second counter, m, is incremented
everytime the operating system was executing when the interrupt occured. During
one minute, you recorded m=658 and n=6000.
● Then, is the proportion that the operating system is being executed. A
95% confidence interval
Confidence intervals
Example
● In R :
Example
> binom.test(658,6000,conf.level=0.95)
Exact binomial test
Example
● In R (a variant):
> prop.test(x=658,n=6000,conf.level=0.95)
1-sample proportions test with continuity correction
0.1019278 0.1179103
sample estimates:
p
0.1096667
Confidence intervals
Recap:
References: