2.5. Exercises#

Exercise 2.1

Imagine you are given a sampled signal \(x[n]\) of \(N\) samples, taken at \(f_s = 8000\) Hz. If you derive a new signal \(y[n]\) by taking every other sample from \(x[n]\):

\[y[n] = x[2\cdot n],\]
  • What is the sampling rate \(f_s\) of \(y[n]\)?

  • What is the sampling period \(t_s\) of \(y[n]\)?

  • How many samples will \(y[n]\) have?

Hint

Be sure to consider what happens when \(N\) is even or odd.

Exercise 2.2

If the sampling rate is \(f_s = 100\) Hz, use the aliasing equation (2.3) to find two aliases for each of the following frequencies:

  • \(f = 100\) Hz

  • \(f = -25\) Hz

  • \(f = 210\) Hz

Exercise 2.3

Imagine that you want to sample a continuous wave \(x(t) = \cos(2\pi \cdot f \cdot t)\) of some arbitrary (known) frequency \(f > 0\). Which sampling rates \(f_s\) would you need to use to produce the following discrete observations by sampling \(x(t)\)? Express your answers as a fraction of \(f\).

  • \(x[n] = 1, 1, 1, 1, \dots\),

  • \(x[n] = 1, 0, -1, 0, 1, 0, -1, 0, \dots\),

  • \(x[n] = 1, \sqrt{1/2}, 0, -\sqrt{1/2}, -1, \dots\).

Which (if any) of these sampling rates satisfy the conditions of the Nyquist-Shannon theorem?

Exercise 2.4

Using the quantize function from this chapter, apply different levels of quantization (varying n_bits from 1 to 16) to a recording of your choice. For each quantized signal, subtract it from the original signal and listen to the difference:

# We need to normalize the signal to cover the same range
# before and after quantization if we're going to compare them.
x_span = x.max() - x.min()
x_diff = x / x_span - quantize(x, n_bits) / 2**n_bits

What does it sound like for each quantization level?