thegreyjoy/ruby-standard-deviation — Issue #1: Incorrect calculation?
Author: backwardm
Created: 2012-01-25 22:29:05+00:00
State: open

Hi, I'm no stats-head, but I'd like to ask a question about your gem.

When you're calculating the standard deviation, why aren't you subtracting 1 from the number of items in the array before dividing them by the sum of deviations?

Again, I'm not sure, but I think the proper way to remove bias from the result is to divide the sum of deviations by n-1 where n is the number of items in the array.

So on line 22 of ruby-standard-deviation/ext/ext/standard_deviation.c++ it should be:

result = sqrt((total_distance_from_mean/(array.size()-1));

instead of

result = sqrt((total_distance_from_mean/array.size()));

I'm not a C++ fella either, so that might be way off.