Standard Deviation

Problem #10

Tags: statistics instructional

Who solved this?

Previous:Square Roots Next:Combinations and Permutations


For some set of data, it is often valuable to know its Standard Deviation (often abbreviated to stdev or σ), which is a direct measure of how "spread out" the data is. If the data is being generated by some semi-random process and is normally distributed, we can make significant statistical predictions about the process by leveraging the stdev.

In order to calculate the stdev, we must first calculate the Variance, which is calculated as the average squared deviation from the mean. Simply put, we first calulate the mean value of the data, then go through each datapoint to find the difference between itself and the mean, square that difference, then take the average of every squared difference.

To find the stdev, simply take the square root of the variance.

For example, for a set of {4, -6, 8, 8}, the mean is 3.5, the squared differences are 0.25, 90.25, 20.25, 20.25, and so the variance is 32.75, and the stdev is approximately 5.772762.

The values used in this problem are unitless, but be aware that the Standard Deviation shares the same units as the values in the set. So if the set contains the values {4mm, -6mm, 8mm, 8mm}, its Standard Deviation would be approximately 5.772762mm.

It should also be stated that in application, there may be slightly different methods for calculating standard deviation when only observing a small sample of the dataset, rather than the entire population. The method described above applies to when the entire population is observed - which will be the method used for problems on this site unless otherwise explicitly specified.

Problem Statement

Input Data
The first line will contain Q, the quantity of values in the set.
Q lines will follow, each holding one integer value from the set.

Answer
The Standard Deviation of the set.
Error should be less than 1e-6.

Example

input data:
6
4
-3
1
4
7
-3

answer:
3.726780
You need to login to get test data and submit solution.