All problems

Z-Scores for Everyone

hardPythonStatisticsLists

Ashcombe Insurance scores applicants on measures that share no units at all — years of driving, annual mileage, past claims — and the risk model has to weigh them together. Standardising a column puts it on a common footing: every value is restated as how many standard deviations it sits above or below that column's own mean, so a column of mileages ends up on the same scale as a column of claim counts. The standardised column must line up row for row with the original, so nothing may be reordered.

Task: Print the standardised version of every value in the column.

Input

The first line holds one integer n, how many values follow. Each of the next n lines holds one value as a plain number, in the row order of the original column. Values may repeat. Treat the column as the complete population being described, not as a sample of a larger one.

Output

n lines, one per input value, in the same order the values arrived. Each line holds that value standardised, with exactly two digits after the decimal point. A value below the column's mean carries a minus sign.

A column can arrive with every value identical — every applicant reporting zero past claims, say. There is no spread to restate anything in, so every line of that column prints 0.00. The program must print those lines rather than stop with an error.

Example:

Input:
4
10
20
30
40

Output:
-1.34
-0.45
0.45
1.34

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…