T-Statistic for a Small Sample
Cadence Coffee trains every barista to a house standard: an espresso shot should take a stated number of seconds to pull. New grinders keep going in across the estate, and the head roaster suspects some of them have quietly changed the timing. Nobody knows the shot-to-shot variability of a new setup, so it has to be estimated from the very same shots being tested.
Each site times a batch of shots and reports how many were timed, their average, and the sample standard deviation of that batch. House standards differ by drink and by site, and the batches are not all the same size.
Task: Print the standardised test statistic for the house standard, rounded to 2 decimals. The conventions: the population standard deviation is unknown and the reported spread is a sample estimate taken from these same shots, so this is a one-sample t-statistic on one fewer degree of freedom than there are shots, not a z-statistic; the alternative is two-sided, because a new grinder could run fast or slow; the gap is the shots' average minus the standard, so a slow batch gives a positive statistic; and rounding happens once, on the final value.
Input
Four lines: the house standard in seconds, how many shots were timed, the average of those shots, and their sample standard deviation. The shot count is a whole number of at least 2; the rest are positive decimals.
Output
One line holding the t-statistic, rounded to 2 decimals and printed the way Python prints a float - 1.33, and negative when the batch runs fast.
Example:
Input:
50
16
52
6
Output:
1.33
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