{ "cells": [ { "cell_type": "markdown", "id": "d0ba2b9b", "metadata": {}, "source": [ "# Wavelet Filtering" ] }, { "cell_type": "markdown", "id": "94cf5ba7", "metadata": {}, "source": [ "Background\n", "--\n", "Other than classical frequency filtering, Wavelet filtering is one of common techniques used in signal processing. It allows to filter out short-time duration patterns captured by used wavelet. The patterns to be filtered out depends on the wavelet family (e.g. *db3*) used and number of level of decomposition. \n", "\n", "Algorithmically, it is very straightforward. Decompose a signal $x(n)$, into wavelet coefficients $X(k)$, where each coefficient represents the strength of wavelet pattern at particular time. With some threshold, remove the coefficients by zeroing out and reconstruct the signal back.\n", "\n", "The machanism to choose a threshold on the strength of wavelet coefficient depends on the application and objective. To remove the noise and compress the signal, a widely used approach is to filter out all the wavelet coefficients with smaller strength.\n", "\n", "Literature [1] suggest the **optimal threshold** on the wavelet coeffiecient is\n", "\n", "$$ \\theta = \\tilde{\\sigma} \\sqrt{2log(N)}$$\n", "where $\\tilde{\\sigma}$ is estimation of noise variance and $N$ length of signal\n", "$$ \\tilde{\\sigma} = median(|X(k)|)/0.6745$$\n", "and $X(k)$ are wavelet coeffients of $x(n)$\n", "\n", "There are other methods to choose threshold too. One can choose a $\\theta =1.5\\times SD(X(k))$ or $\\theta =IQR(X(k))$ as to select the outliers, by standard deviation and interquartile range, respectively.\n", "\n", "According to the theory, the **optimal threshold** should be applied by zeroing out the coefficients below with magnitude lower than threshold $|X(k)|<\\theta$, and for later two methods of thresholds,standard deviation and interquartile range, the coefficients outside of the threshold should be zeroing out, since they reprepresent the outliers. However, some of the (weired) articles use these thresholds in other-way round.\n", "\n", "A simple block-diagram shown below is the procedure of wavelet filtering.\n", "\n", "