Method: Math#variance_sample

Defined in:
lib/openc3/core_ext/math.rb

#variance_sample(array) ⇒ Float

Calculates the sample variance of a group of numbers. If the population of numbers is very large, it is not possible to count every value in the population, so the computation must be performed on a sample of the population.



73
74
75
76
77
78
79
80
# File 'lib/openc3/core_ext/math.rb', line 73

def variance_sample(array)
  mean, m2, num_values = variance_generic(array)
  if num_values != 1.0
    return [mean, m2 / (num_values - 1.0)]
  else
    return [mean, 0.0]
  end
end