SeriesAutocovariance Method (IReadOnlyListDouble, Int32)
public static double Autocovariance( this IReadOnlyList<double> series, int lag )
<ExtensionAttribute> Public Shared Function Autocovariance ( series As IReadOnlyList(Of Double), lag As Integer ) As Double
public: [ExtensionAttribute] static double Autocovariance( IReadOnlyList<double>^ series, int lag )
[<ExtensionAttribute>] static member Autocovariance : series : IReadOnlyList<float> * lag : int -> float
In a length-N time series, there are N-k lag-k observations. Nonetheless, the definition of the lag-k auto-covariance requires division by N, not N-k. This counterintuitive convention ensures that the auto-covariance has desirable positive definiteness properties and agrees with the computation via FFT.
The computation of an auto-covariance via this method is O(N). If you need to compute more than a handful of auto-covariances, it is more efficient to call the Autocovariance(IReadOnlyListDouble), which computes all of them in O(N log N).
While the sample auto-covariance does converge to the population auto-covariance in the large-N limit, this convergence is very slow. If you want an estimate of the population auto-covariance, use SeriesPopulationStatistics(IReadOnlyListDouble) to obtain a much better estimate.