Struct ComplexMorlet
pub struct ComplexMorlet {
pub omega0: f64,
pub bandwidth: f64,
}Expand description
Enhanced Complex Morlet Wavelet for Financial Analysis
The complex Morlet wavelet provides excellent time-frequency localization and is particularly useful for analyzing non-stationary financial time series.
§Mathematical form
ψ(t) = π^{-1/4} · √(2/bw) · exp(-t²/(2·bw²)) · exp(i·ω₀·t/bw)This is the Type-I Morlet convention: both the Gaussian envelope
AND the complex-exponential carrier are scaled by 1/bandwidth. The
wavelet’s spectral peak therefore sits at angular frequency
ω₀ / bandwidth (not ω₀). center_frequency() and
instantaneous_frequency() reflect this — both include the
1/bandwidth factor.
Difference from PyWavelets cmor(B, C): PyWavelets uses
Type-II (exp(2πi·C·t)·exp(-t²/B)) where the carrier stays at
2π·C regardless of B. Code migrating from PyWavelets and using
ferro-wave’s bandwidth ≠ 1 will see the carrier shift; either use
bandwidth = 1 (matches PyWavelets B=1 semantics) or adjust the
ω₀ parameter to compensate.
§Parameters
omega0: Central frequency parameter (typically 5-6 for good localization)bandwidth: Controls time-frequency trade-off; scales both envelope width and carrier frequency by1/bandwidth(see Type-I note above)
§Financial Properties
- Preserves phase information for trend direction analysis
- Optimal for detecting frequency modulations in price data
- Excellent for identifying regime changes through instantaneous frequency
Fields§
§omega0: f64Central frequency parameter (ω₀)
bandwidth: f64Bandwidth parameter for time-frequency localization
Implementations§
§impl ComplexMorlet
impl ComplexMorlet
pub fn for_finance() -> Self
pub fn for_finance() -> Self
Create Complex Morlet with optimal parameters for financial analysis
Uses ω₀ = 6.0 and bandwidth = 1.0 for good time-frequency localization suitable for most financial time series analysis.
pub fn for_hft() -> Self
pub fn for_hft() -> Self
Create Complex Morlet optimized for high-frequency trading analysis
Uses higher ω₀ = 8.0 for better frequency resolution to capture rapid price movements in HFT data.
pub fn for_regime_detection() -> Self
pub fn for_regime_detection() -> Self
Create Complex Morlet optimized for regime detection
Uses lower ω₀ = 4.0 for better time localization to detect sudden regime changes.
pub fn admissibility_constant(&self) -> f64
pub fn admissibility_constant(&self) -> f64
Get the admissibility constant for reconstruction (inherent method — kept for backwards compatibility).
Prefer the trait method ContinuousWavelet::admissibility_constant
which is what icwt(...) calls.
pub fn instantaneous_frequency(&self, scale: f64, sampling_freq: f64) -> f64
pub fn instantaneous_frequency(&self, scale: f64, sampling_freq: f64) -> f64
Compute instantaneous frequency at a given scale.
The wavelet’s effective carrier in η-space is ω₀/bandwidth
(because wavelet_function uses phase = ω₀·t/bandwidth —
envelope and carrier are both scaled by 1/bandwidth). The
instantaneous frequency at scale a is therefore
(ω₀ / bandwidth) / (2π · a) · fs.
Pre-2.0.0 this method ignored bandwidth, producing values that
disagreed with the wavelet’s actual spectral peak by a factor
of bandwidth (1.5× off for for_regime_detection, 1.25× off
for for_hft). Fixed in 2.0.0; users that previously
double-corrected for bandwidth need to update.
Trait Implementations§
§impl Clone for ComplexMorlet
impl Clone for ComplexMorlet
§fn clone(&self) -> ComplexMorlet
fn clone(&self) -> ComplexMorlet
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl ContinuousWavelet for ComplexMorlet
impl ContinuousWavelet for ComplexMorlet
§fn admissibility_constant(&self) -> f64
fn admissibility_constant(&self) -> f64
ComplexMorlet admissibility constant.
Closed form: C_ψ = 2π · bandwidth / ω₀, equivalently
C_ψ = 2π / ω_peak where ω_peak = ω₀/bandwidth is the
spectral peak (matches center_frequency()). The factor of 2
vs the analogous real Morlet’s π / ω₀ comes from
ComplexMorlet’s √(2/bw) amplitude prefactor — the wavelet’s
spectrum has twice the energy at every ω for bw=1, so the
admissibility integral ∫₀^∞ |Ψ̂|²/ω dω doubles.
Empirical match within 1.7% for the for_finance() parameters
(ω₀=6, bw=1): formula → 2π/6 ≈ 1.047, empirical ≈ 1.065.
Residual is the admissibility-correction exp(−ω₀²/2)
contribution (negligible for ω₀ ≥ 5) plus quadrature error.
Calibrated by icwt(cwt(cos)) across multiple frequencies —
see tests/transforms/cwt_reference.rs.
§fn wavelet_function(&self, t: f64, scale: f64) -> Complex<f64>
fn wavelet_function(&self, t: f64, scale: f64) -> Complex<f64>
§fn center_frequency(&self) -> f64
fn center_frequency(&self) -> f64
§fn is_complex(&self) -> bool
fn is_complex(&self) -> bool
§fn wavelet_function_includes_l2_norm(&self) -> bool
fn wavelet_function_includes_l2_norm(&self) -> bool
wavelet_function already includes the CWT L2 amplitude
factor 1/√a in its return value. Read more§fn recommended_scales(
&self,
signal_length: usize,
_sampling_freq: f64,
) -> Vec<f64>
fn recommended_scales( &self, signal_length: usize, _sampling_freq: f64, ) -> Vec<f64>
§fn supports_frequency_domain(&self) -> bool
fn supports_frequency_domain(&self) -> bool
§fn sst_inversion_constant(&self) -> f64
fn sst_inversion_constant(&self) -> f64
R_ψ = ∫₀^∞ Ψ̂*(ω) dω / ω, used by
crate::transform::sswt_extract_component to recover an
EMD-like component from an SST ridge. Read more§fn wavelet_fft(
&self,
_buffer: &mut [FftComplex<f64>],
_scale: f64,
_fft_size: usize,
)
fn wavelet_fft( &self, _buffer: &mut [FftComplex<f64>], _scale: f64, _fft_size: usize, )
§impl Debug for ComplexMorlet
impl Debug for ComplexMorlet
Auto Trait Implementations§
impl Freeze for ComplexMorlet
impl RefUnwindSafe for ComplexMorlet
impl Send for ComplexMorlet
impl Sync for ComplexMorlet
impl Unpin for ComplexMorlet
impl UnwindSafe for ComplexMorlet
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)§impl<T> IntoEither for T
impl<T> IntoEither for T
§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.