Wavyhas beena little absent in the last period, engaged in several trips. During last trip and reflecting about the sound he heardonthe plane and the strangevibrations thatresonate hewondered: how can we quantify and understand the noise thatsurrounds us?
One of the tool we have to characterize the ‘noise’ is through its Power Spectral Density. The Power spectral density function (PSD) and therefore can show the strength of the variations (energy) as a function of frequency. Looking at the power spectral density of a time series we can understand where the contribution at some frequencies is higher and where lower,
So, PSD is a measure of a signal’s power intensity in the frequency domain and provides a useful way to characterize the amplitude versus frequency content of what we call ‘noise’.
The mathematical representation
The one sided periodogram estimate $$S_x(f)$$ of the power spectral density (PSD) is defined in terms of the Fourier transform of a finite sample of data as
The division by $T$ is what turns an “energy” into a “power”; it also implies that the estimate at a given frequency will be independent on $T$.
The factor $2$ takes into account that we use only positive frequencies.
Note that the dimensions of the PSD:
Practical examples
Now, let’s use a bit of python code to show in practice how we can use the PSD of a signal.
In [1]:
### importing the libraryfrom__future__importprint_functionimportnumpyasnpimportmatplotlib.pyplotasplt%matplotlib inline
fromscipy.fftpackimportfft
sampling=1024nsample=32768dt=1.0/samplingT=nsample*dtx=np.linspace(0.0,nsample*dt,nsample)nu=50.0# frequency in Hz of the sine functionsigma=1.0y=np.sin(nu*2.0*np.pi*x)+sigma*np.random.normal(size=nsample)fig,ax=plt.subplots()ax.plot(x,y,label="Data")
So, in the plot we can clearly identify a Frequncy (the $50$ Hz) on a random noise. If in some way we can listen to these data, we will clearly hear a whistle at that frequency. What happen if we have a more featured surroinding noise?
Let’s simulate data using the model we introduced in our first post of these series, which was based on ARMA serie
In [6]:
importstatsmodels.apiassmfromstatsmodels.tsa.arima_processimportarma_generate_samplenp.random.seed(12345)arparams=np.array([.75,-.25])maparams=np.array([.65,.35])arparams=np.r_[1,-arparams]maparam=np.r_[1,maparams]## simulate a simple sinusoidal functionx=np.linspace(0,100,nsample)y=arma_generate_sample(arparams,maparams,nsample)fig,ax=plt.subplots()ax.plot(x,y,label="Data")
We cannot recognize a single dominant contribution to a given frequency, but we found a forest of lines.
Each of these lines identify the intensity of the signal at the corresponding frequency
If we plot the data in a semilogaritmic plot, we can see better what we call a broad band noise. That is a noise where the spectrum of frequency contributing to it is very wide
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkNoRead more