Select Best Basis

DESCRIPTION:
Uses the "best basis" algorithm to selet optimal wavelet packet and cosine packet transforms (bases).

This function is generic (see Methods); method functions can be written to handle specific classes of data. Classes which already have methods for this function include: pcosts, pcosts.2d, ptable.


USAGE:
best.basis(x, type="wp", J=NULL, costs=attr(x, "pcosts"),
           data=NULL, ...)

REQUIRED ARGUMENTS:
x:
a numeric vector, a univariate time series, a matrix, an image, or an object of pcosts, pcosts.2d, ptable.

OPTIONAL ARGUMENTS:
type:
one of the character strings "wp" or "cp" indicating whether to perform wavelet packet analysis or cosine packet analysis. This argument will be ignored when x is an object of ptable, pcosts or pcosts.2d.
J:
maximum depth of tree-search. This argument applies only for when x is an object of ptable or pcosts. Levels beyond J will be ignored in the best basis selection process. The default is n.levels.
costs:
a numeric vector of length 2^min(J, n.level). The best basis will be selected based on the costs vector. This argument applies only for when x is an object of ptable. The vector costs is typically created by pcosts applied to a ptable object.
data:
the image to be analyzed. Only for when x is a pcosts.2d object. If present, coefficients of the best basis are returned (a matrix of the same size as data), otherwise, a character vector of crystal.names representing the best basis is returned.
...:
additional arguments for wp.table or cp.table when x is a numeric vector; additional arguments for wp.costs.2d or cp.costs.2d when x is a matrix. See wp.table, cp.table, wp.costs.2d, cp.costs.2d for details.

VALUE:
when x is an object of pcosts or an object of pcosts.2d and data is not provided, a character vector of crystal.names is returned. See pcosts.object and pcosts.2d.object for details.

Otherwise, a wavelet packet transform object or a cosine packet transform object is returned. 1-D wavelet packet transforms have class wpt inheriting from classes wp and crystal.vector (if boundary is not infinite) or crystal.list (if boundary=infinite). 1-D cosine packet transforms have class cpt inheriting from classes cp and crystal.vector. See crystal.vector.object and crystal.list.object for details.

2-D wavelet packet and cosine packet transforms have class wpt.2d and cpt.2d, and inherit from class crystal.matrix. See crystal.matrix.object for details.


DETAILS:
The best basis algorithm was developed by Coifman and Wickerhauser and is used to select "optimal" bases (i.e., transforms) from wavelet packet and cosine packet tables. The best basis algorithm finds the wavelet packet or cosine packet transform W which minimizes an additive cost function E. See pcosts for the available cost functions.

If x is a numeric vector or univariate time series, then best.basis will first compute a wavelet packet or cosine packet table (according to type="wp" or "cp) and then select the best basis from the table.

If x is a matrix or an image, then best.basis will first compute a 2D wavelet or cosine packet cost vector (according to type="wp" or "cp) and then select the best basis from the cost vector.

For more details, refer to the section "The Best Basis Algorithm" of the S+WAVELETS User's Manual for details. See also Coifman and Wickerhauser (1992) and Chapter 8 of Wickerhauser (1994).


NOTE:
Yale University has applied for a patent for the best basis algorithm. Anyone using the best basis algorithm for commercial applications should contact Yale University regarding the licensing of its use.

REFERENCES:
Coifman, R. and Wickerhauser, M. V. (1992). Entropy-Based Algorithms for Best Basis Selection. IEEE Transactions on Information Theory, 38 (2): 713-718.

Wickerhauser, M. V. (1994). Adapted Wavelet Analysis -- from theory to software.


SEE ALSO:
best.level , cp.costs.2d , cp.table , pcosts , pcosts.object, pcosts.2d.object , wp.costs.2d , wp.table .

EXAMPLES:
yy <- make.signal("linchirp", 512)    # a linear chirp
yw <- wp.table(yy, wavelet="s8", n.levels=4)
bb <- best.basis(yw)                  # select the best basis
eda.plot(bb)

yc <- cp.table(yy, taper="trig", n.levels=4) bc <- best.basis(yc) eda.plot(bc)

x <- phone-mean(phone) wcost <- wp.costs.2d(x, wavelet="s8", n.levels=3) bb2 <- best.basis(wcost, x) eda.plot(bb2)

ccost <- cp.costs.2d(x, taper="poly1", n.levels=3) bb3 <- best.basis(ccost, x) eda.plot(bb3)