williamjsdavis / OnlineMoments.jl

Calculating conditional moments from streams
MIT License
0 stars 0 forks source link

Online autocorrelation is not O(1) in memory #2

Open williamjsdavis opened 1 year ago

williamjsdavis commented 1 year ago

The implementation of sample autocorrelation from OnlineStats.jl is not O(1) in memory; it appears to be O(N).

function test_acf!(m,N)
    for _ in 1:N
        fit!(m, 0.0)
    end
    return nothing
end
m = AutoCov(nlags)
@show @time test_acf!(m,1000)
@show @time test_acf!(m,10000)
@show @time test_acf!(m,100000)

I might need to roll my own ACF function.

williamjsdavis commented 1 year ago

Output:

  0.000783 seconds (7.92 k allocations: 127.406 KiB)
#= In[61]:2 =# @time(test_acf!(m, 1000)) = nothing
  0.004386 seconds (90.00 k allocations: 1.373 MiB)
#= In[61]:3 =# @time(test_acf!(m, 10000)) = nothing
  0.038020 seconds (900.00 k allocations: 13.733 MiB)
#= In[61]:4 =# @time(test_acf!(m, 100000)) = nothing