Skip to content

Package to compute estimates of the spectral coherency matrix of time series

Notifications You must be signed in to change notification settings

alexisrosuel/spectral-coherence

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spectral-coherence

Lightweight package to compute estimates of the spectral coherence matrix of time series. Uses apple MLX package.

Here is the most basic usage:

import numpy as np
from spectral_coherence import smoothed_periodograms, coherences 

# generate M independent AR(1) processes with different parameters
n_samples, n_features = 1000, 4
thetas = np.linspace(-0.7, 0.7, n_features)
epsilon = np.random.normal(size=(n_samples, n_features))
y = np.zeros((n_samples, n_features))
y[0, :] = epsilon[0, :]
for t in range(1, n_samples):
    y[t, :] = thetas * y[t-1, :] + epsilon[t, :]

# cast to mx.array, the package only accepts mx.array as input
y = mx.array(y)

# estimate the spectral density and the coherence from the sample 
S_hats, freqs = smoothed_periodograms(y, B=31)
C_hats, freqs = coherences(y, B=31)

About

Package to compute estimates of the spectral coherency matrix of time series

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages