Standard deviation of scores

Standard deviation of scores

DraftKings Statistics Interview Question

DraftKings describes how spread out a set of contest scores is, not just where the middle sits. Two contests with the same average can be very different to play.

Write standard_deviation(values) that returns the population standard deviation, rounded to four decimal places.

Asked of

  • Data Analyst
  • Product Analyst
  • Analytics Engineer
  • Data Scientist
  • ML Engineer

Example 1

Input

values = [2, 4, 4, 4, 5, 5, 7, 9]

Output

2

Example 2

Input

values = [1, 2, 3, 4, 5]

Output

1.4142

Example 3

Input

values = [7, 7, 7]

Output

0

Explanation

For [2, 4, 4, 4, 5, 5, 7, 9] the mean is 5. The squared distances from it average to 4, and the square root of 4 is 2.

Submit also runs 2 hidden test cases that check edge cases.

Similar questions