Test whether discounts change order size
Task
State a hypothesis about the practice orders -- that discounted orders are larger -- decide the test and threshold before looking, run it, and report the result with the effect size as well as the p-value.
Steps
- Write
lab/test/plan.txtbefore calculating anything: the null and alternative hypotheses, the test (a two-sample comparison of means), the significance level 0.05, and which orders are included. - Include orders with a quantity from 1 to 99, leaving out the invalid and the bulk orders. Split them into discounted (discount_pct above 0) and full price.
- Calculate each group's size and mean quantity, the difference, the standard error
sqrt(var_a/n_a + var_b/n_b)using sample variances, z as the difference over the standard error, and the two-sided p-value withmath.erfc. - Record in
lab/test/result.txtthe linesdiscounted: N orders, mean M,full price: N orders, mean M,difference: D,z: Zandp: P, means and difference to three decimal places, z to two and p to three. - Write
lab/test/report.txt: the decision, the size of the difference in plain terms, and one limitation.
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 '^(discounted|full price|difference|z|p): ' lab/test/result.txt
awk -F': ' '/^p: / {print ($2 < 0.05) ? "reject the null" : "do not reject the null"}' lab/test/result.txt
grep -ciE 'null|hypothes' lab/test/plan.txt
993 discounted orders average 2.376 units and 998 full-price orders 2.329: a difference of 0.047 units, z=0.75 and p=0.454, so the null is not rejected. The report should say the data shows no detectable effect of discounts on order size -- and that this is a random, fictional data set, so it says nothing about real customers.
This is an independent study companion for CompTIA Data+ DA0-002 and is not produced by or endorsed by CompTIA.