# Autocorrelation of a vector

**URL:** https://discourse.julialang.org/t/autocorrelation-of-a-vector/50249
**Category:** General Usage
**Tags:** question
**Created:** [November 16, 2020, 9:16pm UTC](https://discourse.julialang.org/t/autocorrelation-of-a-vector/50249 "2020-11-16T21:16:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [November 16, 2020, 9:16pm UTC](https://discourse.julialang.org/t/autocorrelation-of-a-vector/50249/1 "2020-11-16T21:16:25Z")

</div>

[https://juliastats.org/StatsBase.jl/v0.16/signalcorr.html#StatsBase.autocor](https://juliastats.org/StatsBase.jl/v0.16/signalcorr.html#StatsBase.autocor)

> If x is a vector, return a vector of the same length as x.

```julia
julia> length(autocor(randn(2000)))
34

```

Why isn’t the result length 2000?

---

<div class="post-metadata">

### Author: ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)
#### Post date: [November 16, 2020, 9:23pm UTC](https://discourse.julialang.org/t/autocorrelation-of-a-vector/50249/2 "2020-11-16T21:23:21Z")

</div>

[https://juliastats.org/StatsBase.jl/stable/signalcorr/](https://juliastats.org/StatsBase.jl/stable/signalcorr/)

" When left unspecified, the lags used are the integers from 0 to `min(size(x,1)-1, 10*log10(size(x,1)))` ."

```julia
julia> 10*log10(2000)
33.01029995663981

```

lag starting at 0 up to 33 gives 34 lags.
