FFT based covariance estimation in R — Pt. 1

Introduction Consider a vector of $n$ real values1, with entries corresponding to observations on discrete times $t=1,\dots,n$, $$ \boldsymbol x = \begin{pmatrix} x_1 & x_2 & \dots & x_{n} \end{pmatrix}’\in\mathbb R^n. $$ The discrete Fourier transform (DFT) $\{a_j \in \mathbb C\}$ of $\boldsymbol x$ at frequencies $\omega_j =j/n\in[0,2\pi]$, $j=0,1,\dots,n-1$ is defined by $$ \begin{align} a_j = \sum_{t=1}^{n} x_t e^{-i2\pi t\omega_j}. \end{align} $$ The DFT decomposes the time-domain data $\boldsymbol{x}$ into its constituent frequencies, represented by the complex coefficients $a_j$. Each coefficient describes the amplitude and phase of a sinusoidal wave at frequency $\omega_j = j/n$, capturing how much that frequency contributes to the overall data. This transformation reveals the data’s periodic patterns in the frequency domain, laying the groundwork for exploring the periodogram and its connection to the (sample) autocovariance function. ...

April 10, 2020 · 5 min · 993 words · Martin C. Arnold

Note on efficient programming: column-major order

Recently, I’ve been revisiting some of my older code and have noticed how much my understanding of efficient programming has grown. While I’m still exploring whether practice truly leads to perfection, it’s clear that my skills have improved 😊. In examining my past projects, I discovered a seemingly minor oversight that had a significant impact on performance: the choice between iterating over matrix rows versus columns in matrix operations. ...

March 1, 2019 · 4 min · 717 words · Martin C. Arnold