Documentation |
This section takes you through the features of one-dimensional wavelet density estimation using one of the Wavelet Toolbox™ specialized tools.
The toolbox provides a graphical interface tool to estimate the density of a sample and complement well known tools like the histogram (available from the MATLAB^{®} core) or kernel based estimates.
For the examples in this section, switch the extension mode to symmetric padding, using the command
dwtmode('sym')
Start the Density Estimation 1-D Tool.
From the MATLAB prompt, type
wavemenu
The Wavelet Toolbox Main Menu appears.
Click the Density Estimation 1-D menu item. The discrete wavelet analysis tool for one-dimensional density estimation appears.
From the File menu, choose the Load > Data for Density Estimate option.
When the Load data for Density Estimate dialog box appears, select the MAT-file ex1cusp1.mat from the MATLAB folder toolbox/wavelet/wavedemo. Click OK. The noisy cusp data is loaded into the Density Estimation 1-D tool.
The sample, a 64-bin histogram, and the processed data obtained after a binning are displayed. In this example, we'll accept the default value for the number of bins (250). The binned data, suitably normalized, will be processed by wavelet decomposition.
Perform a Wavelet Decomposition of the binned data.
Select the sym6 wavelet from the Wavelet menu and select 4 from the Level menu, and click the Decompose button. After a pause for computation, the tool displays the detail coefficients of the decomposition of the binned data.
Accept the defaults of global soft thresholding. The sliders located on the right of the window control the level dependent thresholds, indicated by yellow dotted lines running horizontally through the graphs on the left of the window.
Continue by clicking the Estimate button.
You can see that the estimation process delivers a very irregular resulting density. The density estimate (in yellow) is the normalized sum of the signals located below it: the approximation a4 and the reconstructed details after coefficient thresholding.
You can experiment with the various predefined thresholding strategies by selecting the appropriate options from the menu located on the right of the window or directly by dragging the yellow lines with the left mouse button. Let's try another estimation method.
From the menu Select thresholding method, select the item By level threshold 2. Next, click the Estimate button.
The estimated density is more satisfactory. It correctly identifies the smooth part of the density and the cusp at 0.7.
The tool lets you save the estimated density to disk. The toolbox creates a MAT-file in the current folder with a name you choose.
To save the estimated density, use the menu option File > Save Density. A dialog box appears that lets you specify a folder and filename for storing the density. Type the name dex1cusp. After saving the density data to the file dex1cusp.mat, load the variables into your workspace:
load dex1cusp whos
Name | Size | Bytes | Class |
---|---|---|---|
thrParams | 1x4 | 464 | cell array |
wname | 1x4 | 8 | char array |
xdata | 1x250 | 2000 | double array |
ydata | 1x250 | 2000 | double array |
The estimated density is given by xdata and ydata. The length of these vectors is of the same as the number of bins you choose in step 4. In addition, the parameters of the estimation process are given by the wavelet name in wname.
wname wname = sym6
and the level dependent thresholds contained in thrParams, which is a cell array of length 4 (the level of the decomposition). For i from 1 to 4, thrParams{i} contains the lower and upper bounds of the interval of thresholding and the threshold value (since interval dependent thresholds are allowed). For more information, see One-Dimensional Adaptive Thresholding of Wavelet Coefficients. For example, for level 1,
thrParams{1} ans = 0.0560 0.9870 2.1179
Note When you load data from a file using the menu option File > Load Data for Density Estimate, the first one-dimensional variable encountered in the file is considered the signal. Variables are inspected in alphabetical order. |
At the end of this section, turn the extension mode back to zero padding using
dwtmode('zpd')