# 10.5: Exercises

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$ $$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$ $$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$ $$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$

1. The goal when smoothing data is to improve the signal-to-noise ratio without distorting the underlying signal. The data in the file problem10_1.csv consists of four columns of data: the vector x, which contains 200 values for plotting on the x-axis; the vector y, which contains 200 values for a step-function that satisfies the following criteria

$y = 0 \text{ for } x \le 75 \text{ and for } x \ge 126 \nonumber$

$y = 1 \text{ for } 75 < x < 126 \nonumber$

the vector n, which contains 200 values drawn from random normal distribution with a mean of 0 and standard deviation of 0.1, and the vector s, which is the sum of y and n. In essence, y is the pure signal, n is the noise, and s is a noisy signal. Using this data, complete the following tasks:

(a) Determine the mean signal, the standard deviation of the noise, and the signal-to-noise ratio for the noisy signal using just the data in the object s.

(b) Explore the effect of applying to the noisy signal, one pass each of moving average filters of widths 5, 7, 9, 11, 13, 15, and 17. For each moving average filter, determine the mean signal, the standard deviation of the noise, and the signal-to-noise ratio. Organize these measurements using a table and comment on your results. Prepare a single plot that displays the original noisy signal and the smoothed signals using widths of 5, 9, 13, and 17, off-setting each so that all five signals are displayed. Comment on your results.

(c) Repeat the calculations in (b) using Savitzky-Golay quadratic/cubic smoothing filters of widths 5, 7, 9, 11, 13, 15, and 17; see the original paper for each filter's coefficients.

(d) Considering your results for (b) and for (c), what filter and what width provides the greatest improvement in the signal-to-noise ratio with the least distortion of the original signal’s step-function? Be sure to justify your choice.

2. The file problem10_2.csv consists of two columns, each with 1024 points: x is an index for the x-axis and y is noisy data with a hint of a signal. Show that there is a signal in this file by using any one moving average or Savitzky-Golay smoothing filter of your choice and using a Fourier filter. Present your results in a single figure that shows the original signal, the signal after smoothing, and the signal after Fourier filtering. Comment on your results.

3. The file problem 10_3.csv consists of six columns: x is an index for the x-axis and y1, y2, y3, y4, and y5 are signals superimposed on a variable background. Use a Savitzky-Golay nine-point cubic second-derivative filter to remove the background from the data and then build a calibration model using these results, and report the calibration equation and a plot of the calibration curve. See the original paper for the filter's coefficients.

10.5: Exercises is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by David Harvey.