All problems

Testing a Cereal Box Weight Claim

easyPythonHypothesis Testing

Harrow Mills packs breakfast cereal on lines that are each meant to average a stated fill weight per box. Under-filling is a regulatory problem and over-filling is money given away, so every line is audited on a fixed schedule rather than only when someone complains.

Each filling head has been characterised over years of production and its variability is treated as a known constant. An audit pulls a number of boxes off the line and weighs them. The lines pack different products at different target weights, and the audits are not all the same size.

Task: Print the standardised test statistic for the line's target, rounded to 4 decimals. The conventions: the population standard deviation is known rather than estimated from the audited boxes, so this is a z-statistic; the alternative is two-sided, since Harrow cares about heavy boxes as well as light ones; the gap is the audit's average minus the target, so a light batch gives a negative statistic; and rounding happens once, on the final value.

Input

Four lines: the target fill weight the line is set to, the filling head's known population standard deviation, how many boxes the audit weighed, and the average weight of those boxes. All are positive numbers, and the box count is a whole number of at least 1.

Output

One line holding the z-statistic, rounded to 4 decimals and printed the way Python prints a float - -3.0, never -3.0000, and positive when the batch runs heavy.

Example:

Input:
500
10
25
494

Output:
-3.0

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…