1. Concepts & Definitions
1.2. Central Limit Theorem (CLT)
1.5. Confidence interval and normal distribution
1.6. Applying normal confidence interval
1.7. Normal versus Student's T distributions
1.8. Confidence interval and Student T distribution
1.9. Applying Student T confidence interval
1.10. Estimating sample size using normal distribution
1.11. Estimating sample size using Student T distribution
1.12. Estimating proportion using samples
2. Problem & Solution
2.1. Confidence interval for weight of HS6 code
The next numerical example is helpful to illustrate how to employ a confidence interval with normal distribution to estimate the population mean for a specific situation.
A company wants to launch a new product, but before deciding the price, you want to know the average price of all such products on the market. for a sample of 36 similar products an average price of US$ 70.5 was obtained and a standard deviation of US$ 4.5 for all products. What is the IC of 90% for the average price?
For this example: n (sample size) = 36, x̄ (sample mean) = 70.5, σ standard deviation of the population (use sample standard deviation s if population standard deviation is unknown) = 4.5, and z α/2 (critical value) = 1.645.
The interval confidence estimation for the population mean using sample data is given by:
μ = x̄ +- z α/2 * s/(n^0.5).
μ = 70.5 +- 1.645 * 4.5/(36^0.5)
= 70.5 +- 1.645 * 4.5/6
= 70.5 +- 1.645 * 0.75
= 70.5 +- 1.23
= [69.27, 71.73]
The next code in Python helps to automate the computation of confidence interval using a normal distribution. This could be easily adapted to any other numerical example which fullfill the same conditions.
from scipy.stats import norm
n = 36 # Sample size
x = 70.5 # Mean od the sample
sigma = 4.5 # Sample standard deviation
p = 0.90 # Confidence level: population percentage covered by the interval
muz = 0 # mean of the standard normal
sigmaz = 1 # standard deviation of standard normal
alfa = 1-p # obtaining the significance level: alpha
pr = 1-alfa/2 # percentage of the population higher than the critical level z
z = norm.ppf(pr, muz, sigmaz) # computing the critical z alpha/2
mux = x # using sample as a estimator to population mean
sigmax = sigma/(n**0.5) # normalized standard deviation
marg = z*sigmax # margin of error
mux1 = x - marg # lower critical value
mux2 = x + marg # upper critical value
print('CI with ',p*100,'% = [ ',round(mux1,2),',',round(mux2,2),']') # Confidence interval
CI with 90.0 % = [ 69.27 , 71.73 ]
The previous complete code is available in the following link:
https://colab.research.google.com/drive/1cu23CwaHnV-gDqTNrPFnnUAS0fIsnjFP?usp=sharing