Draw a sample, measure its error, and put an interval on a mean

short · 40 min · Objective 3.2

Task

Take a systematic sample of the orders and compare its mean with the whole population's, then calculate a 95% confidence interval for the survey's mean satisfaction score.

Steps

  1. Sort data/orders.csv by order_id and take every 20th order, starting with the 20th. Record in lab/sample/compare.txt the lines sample size: N, sample mean quantity: N and population mean quantity: N, means to three decimal places.
  2. Count how many of the six bulk orders (quantity of 100 or more) the sample contains, and record bulk orders in sample: N.
  3. For the survey's satisfaction scores, calculate the mean, the standard error (sample standard deviation divided by the square root of n) and the 95% interval as mean plus or minus 1.96 standard errors. Record interval: LOW to HIGH in lab/sample/interval.txt, to two decimal places.

Verify

These checks run in a POSIX shell with Python 3: Terminal on macOS or Linux, and on Windows Git Bash (it comes with Git for Windows) or WSL. On Windows, python3 is often a Microsoft Store placeholder that prints “Python was not found”; run alias python3=py in Git Bash first.

grep -E '^(sample size|sample mean quantity|population mean quantity|bulk orders in sample): ' lab/sample/compare.txt
grep -E '^interval: ' lab/sample/interval.txt

A sample of 100 has a mean quantity of 2.370 against the population's 2.845, and it contains 0 of the bulk orders: rare extremes are exactly what small samples miss. The survey's mean satisfaction has a 95% interval of 3.39 to 3.76 -- a statement about the 200 respondents' uncertainty, which says nothing about whether the respondents represent all customers.

This is an independent study companion for CompTIA Data+ DA0-002 and is not produced by or endorsed by CompTIA.