White noise is a signal whose power spectrum is homogeneously distributed across frequencies. In this chapter we are going to generate a long random signal by using `rand' with the option `normal'. Then we will calculate its power spectrum.
Once we have produced a `flat' power spectrum coming from Gaussian noise, we can eliminate some frequencies by filtering to get `colored noise'. We can check the behavior of a system by comparing both spectra.
The next code designs a low-pass filter at 0.25 Hz and applies the filter to white noise. Notice that frequencies above 50 are negative corresponding to
-->rand('normal');
-->rand('seed',0);
-->x = rand(1,20000);
-->lysis = iir(5,'lp','butt',[.25 0],[0 0]);
-->y = flts(x,lysis);
-->N = 100;
-->inct = 1;
-->incf = 1 / (N * inct);
-->fre = [0:(N-1)] * incf;
-->xbasc()
-->xsetech([0,0,1/2,1/2])
-->plot (x(1:100))
-->xsetech([1/2,0,1/2,1/2])
-->plot2d(fre,pspect(50,100,'re',x));
-->xsetech([0,1/2,1/2,1/2])
-->plot(y(1:100));
-->xsetech([1/2,1/2,1/2,1/2])
-->plot2d(fre,pspect(50,100,'re',y));
![]() |
If we regroup the frequency axis to show the effect of the filter, we can clearly see the proper behavior of the filter.
Now we can repeat the process by applying a high-pass filter
-->lysis = iir(5,'hp','butt',[.25 0 ],[0 0]); -->y = flts(x,lysis); -->xbasc() -->xsetech([0,0,1/2,1/2]) -->plot (x(1:100)) -->xsetech([1/2,0,1/2,1/2]) -->plot2d(fre,pspect(50,100,'re',x)); -->xsetech([0,1/2,1/2,1/2]) -->plot(y(1:100)); -->xsetech([1/2,1/2,1/2,1/2]) -->plot2d(fre,pspect(50,100,'re',y));
![]() |
We can see that we start with white noise whose spectrum is homogeneously distributed and we eliminate some frequencies by filtering. In the left frames we can see the effect in time domain. The disappearance of some frequencies is also evident without spectral analysis.
We could generalize this idea and consider a signal (for instance an EEG trace) as the result of applying a filter to white noise. We could study the parameters of this filter as a way to simplify the description of the signal or to analyze its modifications in time (for instance to detect the transition between wakefulness and sleep).