from scipy.io import loadmat
import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import spectrogram
Analyzing Rhythms Part 2a (Autocovariance)
Load modules we’ll need.
Make the noise signal.
= 1000;
N = 0.001;
dt= "SOMETHING"
T = "SOMETHING"
x = "SOMETHING"
t
plt.plot(t,x)'Time [s]'); plt.xlabel(
Compute the auto-covariance.
= "SOMETHING"
ac_xx = "SOMETHING" # Create a lag axis,
lags # ... and plot the result.
plt.plot(lags, ac_xx) 'Lag [s]')
plt.xlabel('Autocovariance'); plt.ylabel(
Compute the spectrum.
= np.fft.fft(x - x.mean()) # Compute Fourier transform of x
Xf
# Compute the spectrum
= "SOMETHING"
Sxx
# Define a frequency axis.
= np.fft.fftfreq(N, dt)
f
# Plot the result.
plt.plot(f, Sxx)