The Welch method is an improvement (it reduces noise) of the periodogram technique and is named after P.D. Welch. The noise of the power spectrum is reduced with the following steps:
We will also explore the Fano factor, which is given as follows:
It is a windowed variance-to-mean ratio. Dividing by the mean basically normalizes the values, and we get a normalized measure of dispersion. As input data we will use temperature data.
from scipy import signal import matplotlib.pyplot as plt import dautil as dl from IPython.display import HTML
fs = 365 temp = dl.data.Weather.load()['TEMP'].dropna() fano_factor = dl.ts.fano_factor(temp, fs)
def plot_welch(arr, ax): f, Pxx_den = signal.welch(arr, fs) ax.semilogy(f, Pxx_den)
sp = dl.plotting.Subplotter(2, 2, context) temp.plot(ax=sp.ax) sp.label(ylabel_params=dl.data.Weather.get_header('TEMP')) sp.label(advance=True) sp.ax.plot(temp.index, fano_factor) sp.label(advance=True) plot_welch(temp, sp.ax) sp.label(advance=True) plot_welch(fano_factor.dropna(), sp.ax) HTML(sp.exit())
Refer to the following screenshot for the end result:
The code is in the estimating_welch.ipynb
file in this book's code bundle.
welch()
function documented at https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.welch.html#scipy.signal.welch (retrieved September 2015)