How Big a Sample Do You Need?
Customers tell Ridgeline what they need before the lab books any rig time: the certificate must be tight enough that the true value is pinned to within some stated distance either side of the measured average, at a stated confidence level. Each rig has its own known population standard deviation.
Rig time is billed by the reading, so the scheduler wants the smallest number that will actually satisfy the requirement - no readings bought that are not needed, and none missing that are.
Task: Print the minimum number of readings, as a whole number. The conventions: the required distance is a half-width, the distance to one endpoint, not the total span; the requirement is "at most that distance", so any count whose margin comes out above it fails; the population standard deviation is known, so the supplied normal critical value applies; and the answer is rounded up to a whole number, never to nearest.
Input
Three lines: the largest margin of error the customer will accept, the rig's known population standard deviation, and the critical value for the confidence level required. All three are positive decimals.
Output
One line holding the number of readings, as a plain integer - 97, never 97.0.
Example:
Input:
2
10
1.96
Output:
97
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