Created
June 17, 2021 15:48
-
-
Save noahtren/8af3cd551500972473eb2c12efce075a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import numpy as np | |
def normalize_freq_coeff(coeff): | |
freqs = np.fft.fftfreq(coeff.shape[-1], d=1 / coeff.shape[-1]) | |
scale = (1 / (np.abs(freqs) + 1)) | |
return coeff * scale | |
def eq(signal): | |
X = [] | |
for i, val in enumerate(signal): | |
if i > 0: | |
X.append(val + signal[i - 1]) | |
else: | |
X.append(val) | |
return np.array(X) | |
coeffs = np.random.normal(size=[100]) + np.random.normal(size=[100]) * 1j | |
norm = normalize_freq_coeff(coeffs) | |
signal = np.fft.ifft(norm).real | |
signal = np.tile(signal, 6) | |
eq_signal = eq(signal) | |
plt.plot(signal) | |
plt.plot(eq_signal) | |
plt.gca().set_ylim([-0.1, 0.1]) | |
plt.show() |
Author
noahtren
commented
Jun 17, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment