#157easyStatistics
Confidence Interval for Mean
Time Limit: 2sMemory: 256MB
Problem
Given a sample of n values and a confidence level (as a percentage), compute the confidence interval for the population mean.
Use the sample mean, sample standard deviation, and the z-value corresponding to the confidence level.
Input Format
- Line 1: integer
n - Line 2:
nspace-separated floating-point values - Line 3: confidence level (e.g.,
95)
Output Format
Two space-separated values: lower upper, each to 4 decimal places.
Examples
Example 1
Input(Line 1: integer n)
5 10 12 14 16 18 95
Output
11.2282 16.7718
Mean = 14, s = 3.1623, z = 1.96, margin = 1.96 * 3.1623 / sqrt(5) = 2.7718.
Example 2
Input(Line 1: integer n)
6 5 7 9 11 13 15 90
Output
7.4874 12.5126
Mean = 10, s = 3.7417, z = 1.6449, margin = 1.6449 * 3.7417 / sqrt(6) = 2.5126.
Constraints
- •2 <= n <= 10000
- •Values are floating-point numbers in [-10000, 10000]
- •Confidence level is one of 80, 90, 95, or 99
Loading interactive editor…