lib/more_math/sequence.rb
# Returns the array of autovariances (of length size - 1).
Returns the array of autovariances (of length size - 1).
Returns the array of autovariances ( of length size - 1 ) .
def autovariance
      Array.new(size - 1) do |k|
        s = 0.0
        0.upto(size - k - 1) do |i|
          s += (@elements[i] - arithmetic_mean) * (@elements[i + k] - arithmetic_mean)
        end
        s / size
      end
    end
def autovariance Array . new ( size - 1 ) do | k | s = 0.0 0 . upto ( size - k - 1 ) do | i | s += ( @elements [ i ] - arithmetic_mean ) * ( @elements [ i + k ] - arithmetic_mean ) end s / size end end
Returns the array of autovariances (of length size - 1).
Returns the array of autovariances ( of length size - 1 ) .