P-Value for the Cereal Box Test
The Harrow Mills cereal audits each produce a standardised statistic. The plant manager's reaction is always the same: "three sounds like a lot, but how unlikely is it really?" That is the question a p-value answers, and it is the number that has to go in every audit report next to the statistic - for the lines that ran light, the lines that ran heavy, and the ones that barely moved.
The browser Python this site runs has no statistics packages installed, so the normal curve has to come from math.erf, which is available.
Task: Print the p-value for the statistic supplied, rounded to 4 decimals. The conventions: the reference distribution is the standard normal, not a t distribution; the test is two-sided, so departures in both directions count towards the total; the p-value is the chance of a statistic at least this extreme assuming the line's target is exactly right; and rounding happens once, on the final value.
Input
One line holding the audit's standardised statistic, a decimal which may be negative.
Output
One line holding the p-value, rounded to 4 decimals and printed the way Python prints a float - 0.0027.
Example:
Input:
-3.0
Output:
0.0027
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