0
I have the following array [123, 350, 3456, 98]
and need to remove items outside the standard deviation as in this case the 3456. I have already calculated the standard deviation as below:
class Array
def average
return 0 unless self.size > 0
self.sum / self.size
end
def deviation
average = self.average
sum = 0
self.map { |ar| sum += ar - average }
variance = sum / (self.size - 1)
Math.sqrt(variance)
end
end
And to get the bypass just run: [123, 350, 3456, 98].deviation # => 1.0
But now I don’t know how it could help me to remove the 3456.