AllenDowney / ThinkDSP

Think DSP: Digital Signal Processing in Python, by Allen B. Downey.
https://allendowney.github.io/ThinkDSP/
3.93k stars 3.2k forks source link

Correction on Chapter 5 test functions #72

Closed necronet closed 3 years ago

necronet commented 4 years ago

A minor point on reading about Discrete cosine transform chapter, there are two test function describe to build an M matrix (see bellow). The amp array is not used in any of them so it should be remove to avoid confusion.

Source: https://github.com/AllenDowney/ThinkDSP/blob/master/code/chap06.ipynb

def test1():
    amps = np.array([0.6, 0.25, 0.1, 0.05])
    N = 4.0
    time_unit = 0.001
    ts = np.arange(N) / N * time_unit
    max_freq = N / time_unit / 2
    fs = np.arange(N) / N * max_freq
    args = np.outer(ts, fs)
    M = np.cos(PI2 * args)
    return M

def test2():
    amps = np.array([0.6, 0.25, 0.1, 0.05])
    N = 4.0
    ts = (0.5 + np.arange(N)) / N
    fs = (0.5 + np.arange(N)) / 2
    args = np.outer(ts, fs)
    M = np.cos(PI2 * args)
    return M

M = test2()
M
AllenDowney commented 3 years ago

Will fix. Thank you!