5 kyu
Calculate Variance
71 of 2,580eerwitt
Description:
Write a function which will accept a sequence of numbers and calculate the variance for the sequence.
The variance for a set of numbers is found by subtracting the mean from every value, squaring the results, adding them all up and dividing by the number of elements.
For example, in pseudo code, to calculate the variance for [1, 2, 2, 3]
.
mean = (1 + 2 + 2 + 3) / 4
=> 2
variance = ((1 - 2)^2 + (2 - 2)^2 + (2-2)^2 + (3 - 2)^2) / 4
=> 0.5
The results are tested after being rounded to 4 decimal places using Javascript's toFixed method.
Statistics
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Oct 22, 2013 |
Published | Oct 22, 2013 |
Warriors Trained | 3455 |
Total Skips | 228 |
Total Code Submissions | 5499 |
Total Times Completed | 2580 |
CoffeeScript Completions | 71 |
JavaScript Completions | 1229 |
Haskell Completions | 82 |
Python Completions | 1233 |
COBOL Completions | 9 |
Total Stars | 39 |
% of votes with a positive feedback rating | 86% of 352 |
Total "Very Satisfied" Votes | 266 |
Total "Somewhat Satisfied" Votes | 70 |
Total "Not Satisfied" Votes | 16 |