pub fn max_modwt_level(signal_length: usize, filter_length: usize) -> usizeExpand description
Calculate maximum decomposition level for MODWT
The maximum level J is constrained by: 2^J * (L-1) < N where:
- J is the decomposition level
- L is the filter length (number of wavelet coefficients)
- N is the signal length
This constraint ensures that the dilated filter at level J doesn’t exceed the signal length. At level J, the filter is dilated by a factor of 2^J, creating gaps between filter coefficients.
§Why this constraint exists:
Unlike DWT which downsamples by 2 at each level, MODWT keeps all coefficients but dilates (upsamples) the filters. At level J:
- The filter spans (2^J * (L-1) + 1) samples due to dilation
- This span must fit within the signal length N for valid convolution
§Examples
-
Signal length 1024, Haar wavelet (L=2): max level = 9
- 2^9 * (2-1) = 512 < 1024 ✓
- 2^10 * (2-1) = 1024 ≥ 1024 ✗
-
Signal length 1024, DB4 wavelet (L=8): max level = 7
- 2^7 * (8-1) = 896 < 1024 ✓
- 2^8 * (8-1) = 1792 ≥ 1024 ✗
§Financial Time Series Note
For financial applications with long time series (e.g., years of tick data), this usually isn’t a limitation. However, for short windows (e.g., analyzing just a few minutes of data), the maximum level may be restricted, especially with longer wavelets.