aspcore.correlation

Implements autocorrelation and cross-correlation estimators, as well as related useful calculations.

  • Estimation of correlation function and covariance matrix of signal.

  • Sample covariance for vector-valued variable, including the non-zero mean case, even for processing a streaming signal, where the full signal is not available at once.

  • Covariance estimation with optimal linear shrinkage [chenShrinkage2010] and almost optimal non-linear shrinkage [ledoitQuadratic2020].

References

[chenShrinkage2010] Y. Chen, A. Wiesel, Y. C. Eldar, and A. O. Hero, “Shrinkage Algorithms for MMSE Covariance Estimation,” IEEE Trans. Signal Process., vol. 58, no. 10, pp. 5016–5029, Oct. 2010, doi: 10.1109/TSP.2010.2053029. [link]

[ledoitQuadratic2020] O. Ledoit and M. Wolf, “Quadratic shrinkage for large covariance matrices,” Dec. 2020, doi: 10.5167/UZH-176887. [link]

Functions

autocorr(sig, max_lag[, normalize])

corr_matrix(seq1, seq2, lag1, lag2)

Computes the cross-correlation matrix from two signals.

corr_matrix_from_autocorrelation(corr)

The correlation is of shape (num_channels, num_channels, max_lag) corr[i,j,k] = E[x_i(n)x_j(n-k)], for k = 0,...,max_lag-1 That means corr[i,j,k] == corr[j,i,-k]

cov_est_oas(sample_cov, n[, verbose])

Implements the OAS covariance estimator with linear shrinkage from Shrinkage Algorithms for MMSE Covariance Estimation

cov_est_qis(sample_cov, n)

Implements the quadratic-inverse shrinkage, the non-linear shrinkage from "Quadratic shrinkage for large covariance matrices" by Ledoit and Wolf.

get_filter_for_autocorrelation(autocorr)

autocorr is of shape (num_channels, max_lag)

is_autocorr_func(func[, verbose])

An autocorrelation function should be of shape (num_channels, num_channels, max_lag)

is_autocorr_mat(ac_mat[, verbose])

multichannel_acf_from_independent_acf(acf_2d)

Takes a (num_channels, corr_len) autocorrelation function

periodic_autocorr(seq)

seq is a single channel sequence of shape (1, period_length), that should be a single period of a periodic signal

sample_correlation(data[, data2, estimate_mean])

data is a matrix of size (data_dim, num_samples) data2 is an optional matrix of size (data_dim2, num_samples) the cross-correlation is calulcated if this is supplied

Classes

Autocorrelation(forget_factor, max_lag, ...)

Autocorrelation is defined as r_m1m2(i) = E[s_m1(n) s_m2(n-i)] the returned shape is (num_channels, num_channels, max_lag) r[m1, m2, i] is positive entries, r_m1m2(i) r[m2, m1, i] is negative entries, r_m1m2(-i)

SampleCorrelation(forget_factor, size[, ...])

Estimates the correlation matrix between two random vectors v(n) & w(n) by iteratively computing (1/N) sum_{n=0}^{N-1} v(n) w^T(n) The goal is to estimate R = E[v(n) w^T(n)]