Lecture Notes Confidence Intervals
Lecture Notes Confidence Intervals
In statistics, we often want to estimate a population parameter based on a sample. One common
parameter of interest is the population mean. Confidence intervals provide a range of values within
which we believe the true population parameter lies. The confidence interval gives a range of values
that is likely to contain the true population mean. For example, a 95% confidence interval means that we
are 95% confident that the interval contains the true mean.
σ
x̄ ± Z ×
√n
where:
is the sample mean.
x̄
Z is the critical value from the standard normal distribution based on the desired confidence level.
σis the population standard deviation.
nis the sample size.
Confidence Level Z (Standard Normal)
90% 1.645
95% 1.960
99% 2.576
Example 1: Population Standard Deviation Known
Problem: Suppose you want to estimate the average time your students spend on weekly homework
assignments. You collect a sample of 25 students and find that the sample mean time spent on
homework is 4.2 hours. Assuming the population standard deviation is 1.2 hours, find the 95%
confidence interval for the average time spent on homework.
Given Data: - Sample mean ( ): 4.2 hours - Population standard deviation ( ): 1.2 hours - Sample size (
x̄ σ
Confidence Interval:
Conf idence Interval = (x̄ − E, x̄ + E)
So, at a 95% confidence level, the average time spent on homework is estimated to be between 3.73
and 4.67 hours.
Solving the same problem using R-Programming:
# Given data
sample_mean <- 4.2
confidence_level <- 0.95
population_std_dev <- 1.2
sample_size <- 25
# Confidence interval
lower_bound <- sample_mean - margin_of_error
upper_bound <- sample_mean + margin_of_error
# Print results
cat("Confidence Interval:", lower_bound, "to", upper_bound, "\n")
x̄ − μ
t =
s
√n
When the population standard deviation is unknown, we use the T-distribution for Confidence Interval,
σ
Sample size ( ): 30
n
Using the t-value for a 95% confidence level with 29 degrees of freedom (approximately 2.045):
2
E = 2.045 × = 0.748, inches
√ 30
Confidence Interval:
Conf idence Interval = (x̄ − E, x̄ + E)
So, at a 95% confidence level, the average height of the population is estimated to be between 64.252
and 65.748 inches.
Solving the same problem using R-Programming:
# Given data
sample_mean <- 65
confidence_level <- 0.95
sample_std_dev <- 2
sample_size <- 30
# Degrees of freedom
df <- sample_size - 1
# Confidence interval
lower_bound <- sample_mean - margin_of_error
upper_bound <- sample_mean + margin_of_error
# Print results
cat("Confidence Interval:", lower_bound, "to", upper_bound, "\n")
depends on several factors, including the desired confidence level, the margin of error, and the
variability of the population. The formula for calculating the required sample size for estimating the
population mean is given by:
2 2
Z × σ
n = ( )
2
E
2 2
t × s
n = ( )
2
E
Where: is the t-value from the t-distribution based on the desired confidence level and degrees of
t
freedom.
s is the sample standard deviation.
To use these formulas, you’ll need to decide on the desired confidence level (e.g., 90%, 95%, 99%),
specify the margin of error you can tolerate, and, if applicable, have information on the population
standard deviation or be willing to estimate it from a sample.
Example-3
Sample Size Problem
Problem: You want to estimate the average score of students in a class. The population standard
deviation is known to be , and you want the margin of error to be no more than points with a
5 2 95%
E (margin of error) =2
2 2
(1.96) × 5
n = ( )
2
2
# Print result
cat("Required Sample Size:", ceiling(required_sample_size), "\n")
Confidence
Level 0% 50% 60% 70% 80% 90% 95% 98% 99% 99.8% 99.9%
Percentile t .50 t .75 t .80 t .85 t .90 t .95 t .975 t .99 t .995 t .999 t
.9995
One-Tail 0.50 0.25 0.20 0.15 0.10 0.05 0.025 0.01 0.005 0.001 0.0005
Two-Tails 1.00 0.50 0.40 0.30 0.20 0.10 0.05 0.02 0.01 0.002 0.001