def acf(max_lags=nil)
          max_lags ||= (10 * Math.log10(size)).to_i

          (0..max_lags).map do |i|
            if i.zero?
              1.0
            else
              m = mean
              # can't use Pearson coefficient since the mean for the lagged series should
              # be the same as the regular series
              ((self - m) * (lag(i) - m)).sum / variance_sample / (size - 1)
            end
          end
        end
Calculates the autocorrelation coefficients of the series.

The first element is always 1, since that is the correlation
of the series with itself.

@example
ts = Daru::Vector.new((1..100).map { rand })

ts.acf   # => array with first 21 autocorrelations
ts.acf 3 # => array with first 3 autocorrelations