Z-Score Standardization
Quillon Energy wants a second way of putting a column on a common footing, one that is not hostage to a single extreme reading. This one restates every reading as how far it sits from the column's own average, counted in units of the column's own typical spread. That is called standardising: a reading of 0 means dead average, 1 means one typical spread above average, and negatives mean below. The rows in the file are the entire column, not a sample drawn from anything larger, so the spread is worked out over all n readings with no correction for sampling.
Task: Print each reading standardised.
Input
The first line holds one integer n, the number of readings. The second line holds the n readings separated by single spaces. The readings are never all identical.
Output
n lines, one per reading, in the order the readings arrived. Each holds the standardised reading rounded to 4 decimal places, negative sign included where there is one.
Example:
Input:
8
2 4 4 4 5 5 7 9
Output:
-1.5000
-0.5000
-0.5000
-0.5000
0.0000
0.0000
1.0000
2.0000
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