Time-Frequency Analysis![]()
Introduction
The purpose of this project is to code and experiment with four of the primary time-frequency analysis techniques. The four techniques are the short time Fourier transform (STFT.m), the
discrete wavelet (Haar) transform (DWT2.m), the continuous wavelet (Morlet) transform (CWVT.m), and the
pseudo-Wigner distribution (PWD.m). Each of these transforms were coded in MATLAB and tested on a
chirp signal (i.e., an increasing frequency as time increases). After successfully implementing the transforms,
the code was used to investigate a real world signal. In our case, the closing price of Micron Technology stock over a decade was used.
The analysis data (mu.m) is the closing stock price for Micron Technology. It has
long been held that the DRAM memory business has a cyclic revenue stream. Several companies produce DRAMs, but this is usually only one of many sectors within any specific company. Financial figures for any one sector of a company are not generally available. Micron (ticker symbol: MU) has both memory and personal computer sales, but their foundation rests on the semiconductor side. This makes their stock the best indicator of the memory business outside of proprietary financial data.
The data is a bi-monthly sampling of the closing price roughly over a ten year period (256 sample points). The file (mu.m) contains the split adjusted price of the stock. Comments in the file
show the date of the closing price and the split adjustment. The file (mu1.m) contains
the same data as mu.m, but is not split adjusted. The last file, (mu2.m), is the same data as mu1.m, but contains a dollar cost adjustment equal to a 3% annual percentage rate compounded monthly (0.25% / month).
Since we are interested in the cycle of the stock, and not the growth factor, mu2.m data was used. Furthermore, the log (base exp) was applied to flatten the data, and finally, the mean was subtracted. This gives us a zero mean signal with a dollar cost adjustment to the closing price of the stock. The original mu.m and adjusted signal (log(mu2.m)-mean(mu2.m)) are shown at the top of Fig. 2.
The short time Fourier transform (STFT) function is simply the Fourier transform operating on a small section of the data. After the transform is complete on one section of the data, the next selection is transformed, and the output "stacked" next to the previous transform output. This process allows the type of window, window length, and zero padding within the FFT to be adjusted. The window type for our code include rectangular, Hamming, Hanning, and Blackman-Tukey. The results from the chirp signal are shown in Fig. 1. The real world data results are shown in Fig. 2. Only our "best" results are displayed in Fig. 2.
![]()
Figure 1. Short time Fourier transform of chirp.m
![]()
Figure 2. Short time Fourier transform of the real world data
The discrete wavelet Haar transform uses a different basis than the STFT. The STFT uses complex sinusoids, with increasing frequency, which are shaped by the window function. Wavelet transforms, on the other hand, maintain the same number of oscillations within the window, but compress or dilate the window to adjust the frequency. It has other properties such as the function must always be bandpass. A wide variety of basis functions are available. We used the most basic: the Haar wavelet. The results from the chirp signal analysis are shown in Fig. 3 with varying degrees of resolution in frequency (~ scales).
![]()
Figure 3. Discrete wavelet (Haar) transform of chirp.m
![]()
Figure 4. Discrete wavelet (Haar) transform the real world data
The Continuous Wavelet Transform (CWT) has much in common with the Short Time
Fourier Transform (STFT). The big difference is that the windowing function
shifts frequency by scaling rather than modulating . The
equation for the CWT is as follows: ![]() where x is the signal, w is the wavelet function, and s is the scale variable (dimensionless). The wavelet function is analogous to the windowing function of the STFT and scale is analogous to frequency. The wavelet function must be square integrable and be bandpass (have no energy at zero frequency). We used a real Morlet Wavelet, which holds for the above properties and has the following form: ![]() where sigma is the approximate bandwidth and fo is the center frequency. The following figure shows examples of the Morlet wavelet function at three different scales, along with the corresponding frequency domain information.
![]()
Figure 5. Morlet wavelet at different scales
![]()
Figure 6. Continuous wavelet transform of a linear chirp signal
Next we tested the CWT on real world data. "mu2.m" was used as our signal, with the adjustments to this signal explained in the "Real World Data" section above. The following figure shows the CWT of this input data.
![]()
Figure 7. Continuous wavelet transform of real world data
The MATLAB function PWD.m calculates the pseudo-Wigner distribution. The function was tested with the chirp signal in chirp.m and the result is shown in Fig. 8.
![]()
Figure 8. Pseudo-Wigner distribution of a linear chirp signal
We obtained the Wigner distribution of the real world data "mu2.m" to analyze its time-frequency characteristics. The result is shown in Fig. 9. Most of the variations are slow (low frequency) with period greater than a year. The distribution shows a low frequency component at a normalized frequency of around 0.007 (approximately a period of 5.9 years) for most of the time duration. This is expected from the earlier results using the STFT.
![]() Figure 9. Pseudo-Wigner distribution of the real world data
We see from all of the analysis techniques that strong low frequency components exist. From the STFT and pseudo-Wigner distribution, the fundamental frequency is in a range between 4.6 to 5.9 years. A secondary harmonic appears in the STFT at 1.7 years. Basically, all the techniques gave some information, but specific information about this particular real world signal was best obtained through the pseudo-Wigner distribution and STFT. The implications are, if history repeats itself, that an investor should expect to wait between 0.9 to 3 years (half the range of the cycle period) to maximize their money, but at the same time, the cyclic nature assures a predictable gain. We wish all investors "happy hunting" if they want to use this data and conclusions to forecast Micron stock. A best guess puts the next cycle peak in the data at approximately March-May, 2000. Invest today at ($39.5 / share on 5/11/99) and check the price in a year! Realize, however, that this predicts the cycle peak and not any given daily peak. From the data, the daily peaks can rise dramatically above the moving average. |