Skip to content

Instantly share code, notes, and snippets.

@noahtren
Created June 17, 2021 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noahtren/8af3cd551500972473eb2c12efce075a to your computer and use it in GitHub Desktop.
Save noahtren/8af3cd551500972473eb2c12efce075a to your computer and use it in GitHub Desktop.
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()
@noahtren
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment