Karhunen–Loève Approximation of Brownian Motion

Playing around with time series data in Observable, I decided to create a small interactive application to visualize the Karhunen-Loève (KL) approximation (Karhunen 1947) of Brownian motion. The widget at the end of this post lets you explore how KL works, illustrating how adding more terms in the series leads to increasingly accurate representations of Brownian paths. ...

May 2, 2023 · 3 min · 558 words · Martin Christopher Arnold

FFT based covariance estimation in R — Pt. II

In the previous post, I discussed an approach to obtain autocovariances1 of time series data through discrete Fourier transforms that I implemented in an R function acf_fft_R(). # ACF using FFT in R acf_fft_R <- function(x) { n <- length(x) a_j <- fft(x) I_x <- Mod(a_j)^2/n return( Re(fft(I_x, inverse = T)/n) ) } An RcppArmadillo version Recently, I wrote an Armadillo version for an Rcpp project. Here’s its definition and how to source it using Rcpp: ...

April 16, 2020 · 9 min · 1796 words · Martin C. Arnold

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