Skip to content

Conversation

@ryanhammonds
Copy link
Member

@ryanhammonds ryanhammonds commented Aug 28, 2024

I finished the math connecting ACF <-> PSD <-> AR(1) in the context of timescales. A summary of the added notebook:

1. ACF as an AR(1)

The ACF can be represented in terms of the AR(1) coefficient, $\varphi$.

$$ \begin{align} A(t) &= e^{\frac{-t}{\tau f_s}} \\ &= \varphi^t \\ \end{align} $$

2. PSD is equal the the abs(fft(A(t))^2, giving the AR(1) spectral form

The AR(1) PSD is the the spectral representation of an exponentially decaying ACF, $A(t)$, confirmed using the Fourier transform and Wiener–Khinchin theorem.

$$ \begin{align} FFT(f) &= \sum_{t=-\infty}^{\infty} \left(\varphi e^{-i 2 \pi f \frac{1}{f_s}}\right)^t \\ &= \frac{1}{1 - \varphi e^{-i 2 \pi f \frac{1}{f_s}}} \\\ P(f) &= |FFT(f)|^2 \\ &= \frac{1}{|1-\varphi e^{-i2\pi f \frac{1}{f_s}}|^2} \end{align} $$

3) Lorentzian Bias

The common Lorentzian spectral form is:

$$ P(f) = \frac{1}{f_k^2 f^2} $$

The notebook shows how to derive this from the AR(1) spectral form. This requires two approximations that introduce bias to timescale estimation: a cosine approximation and an approximation of $\frac{1-\varphi}{\sqrt{\varphi}}$. This bias increases as $\varphi$ becomes smaller, timescales become shorter, or as the knee frequency approaches the Nyquist frequency. Instead, it's recommended to learn $\varphi$ and $\tau$ from the unbiased AR(1) spectral form:

$$ \begin{align} P(f) &= \frac{1}{|1-\varphi e^{-i2\pi f \frac{1}{f_s}}|^2} \\ &= \frac{1}{1 - 2 \varphi \cos{(2 \pi f \frac{1}{f_s})} + \varphi^2} \end{align} $$

where

$$ \begin{align} \tau &= -\frac{1}{\ln(\varphi) f_s} \end{align} $$

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.82%. Comparing base (57a8340) to head (4945d29).

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #33   +/-   ##
=======================================
  Coverage   81.82%   81.82%           
=======================================
  Files          28       28           
  Lines        1128     1128           
=======================================
  Hits          923      923           
  Misses        205      205           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants