I am calculating an autocorrelation function of a signal using Numpy's FFT by first calculating the power spectrum. I believe that autocorrelation functions are positive definite. However, when I test if my simulated autocorrelation function is positive definite, it often fails. Here's some example code:
import numpy as np
def is_pos_def(x):
return np.all(np.linalg.eigvals(x) > 0)
n = 5
signal = np.random.random(size=(n,n)) #create a real valued signal
F = np.fft.fftn(signal) #FFT of real signal is conjugate symmetric
A = np.abs(F) #amplitudes/magnitudes
ps = A**2 #power spectrum is square of magnitudes
acf = np.fft.ifftn(ps) #autocorrelation function is ifft of the power spectrum
acf = acf.real #.real to clean up since the acf is real anyways by definition, and indeed the imaginary terms are zero.
print(is_pos_def(acf))
This outputs False
. Am I missing something?