ComplexMorlet

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 by 1/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: f64

Central frequency parameter (ω₀)

§bandwidth: f64

Bandwidth parameter for time-frequency localization

Implementations§

§

impl ComplexMorlet

pub fn new(omega0: f64, bandwidth: f64) -> Self

Create a new Complex Morlet wavelet

§Arguments
  • omega0 - Central frequency parameter (recommended: 5-6)
  • bandwidth - Bandwidth parameter (recommended: 1.0-2.0)
§Examples
use ferro_wave::transform::complex_wavelets::ComplexMorlet;
let wavelet = ComplexMorlet::new(6.0, 1.0);

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

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

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

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

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

§

fn clone(&self) -> ComplexMorlet

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl ContinuousWavelet for ComplexMorlet

§

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>

Get the wavelet function value at position t for scale a
§

fn center_frequency(&self) -> f64

Get the center frequency of the wavelet
§

fn bandwidth(&self) -> f64

Get the bandwidth parameter
§

fn is_complex(&self) -> bool

Check if the wavelet is complex-valued
§

fn wavelet_function_includes_l2_norm(&self) -> bool

Whether 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>

Get recommended scale range for a given signal length and sampling frequency
§

fn supports_frequency_domain(&self) -> bool

Check if this wavelet supports direct frequency-domain computation Read more
§

fn sst_inversion_constant(&self) -> f64

Synchrosqueezing inversion constant 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, )

Compute the wavelet directly in frequency domain (if supported) Read more
§

impl Debug for ComplexMorlet

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Default for ComplexMorlet

§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoEither for T

§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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>
where F: FnOnce(&Self) -> bool,

Converts 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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,