lib/tealeaves/moving_average.rb
# Calculates the moving average for the given array of numbers.
#
# Moving averages won't include values for terms at the beginning or end of
# the array, so there will be fewer numbers than in the original.
Calculates the moving average for the given array of numbers.
Moving averages won't include values for terms at the beginning or end of
the array, so there will be fewer numbers than in the original.
Calculates the moving average for the given array of numbers . Moving averages won ' t include values for terms at the beginning or end of the array so there will be fewer numbers than in the original .
def calculate(array)
      return [] if @span > array.length
      array.each_cons(@span).map do |window|
        window.zip(weights).map {|(a,b)| a * b }.inject(&:+)
      end
    end
def calculate ( array ) return [ ] if @span > array . length array . each_cons ( @span ) . map do | window | window . zip ( weights ) . map { | ( a , b ) | a * b } . inject ( & :+ ) end end
Calculates the moving average for the given array of numbers.
Calculates the moving average for the given array of numbers .
array
<not_specific>