Last active
August 17, 2018 13:29
-
-
Save sergeyprokudin/febdb301d1c935d5bac3a8d7a600034a to your computer and use it in GitHub Desktop.
Inverse Discrete Cosine Transform
This file contains 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
#http://www.svcl.ucsd.edu/courses/ece161c/handouts/DCT.pdf | |
import numpy as np | |
import matplotlib.pyplot as plt | |
pi = np.pi | |
N = 50 # timesteps | |
k = 10 # n basis functions | |
coefs = np.random.rand(k) #generate random coeficients | |
ns = np.tile(np.arange(0, N, 1).reshape([N, 1]), [1, k]) | |
coefs = np.tile(coefs.reshape([1, k]), [N, 1]) | |
ks = np.tile(np.arange(0, k), [N, 1]) | |
out = 1/N * np.sum(coefs *np.cos( (pi * ks * (2*ns + 1)) / (2*N)), axis=1) | |
plt.plot(ns[:, 0], out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment