Math Functions

This module provides scalar implementations of common analytical filter functions used in Spectral Graph Signal Processing. These are useful for generating target functions for polynomial or rational approximations.

Low-Pass

lowpass(x, scale=1.0)[source]

Computes the spectral response of a low-pass filter.

\[\phi_s(\lambda) = \frac{1}{s\lambda + 1}\]

This filter attenuates high-frequency (large eigenvalue) components while preserving low-frequency structure.

Parameters:
  • x (ndarray) – Input array of eigenvalues \(\lambda\).

  • scale (float, default: 1.0) – The scale parameter \(s\). Larger values shift the cutoff to lower frequencies.

Returns:

The filter’s gain at each point in x.

Return type:

ndarray

High-Pass

highpass(x, scale=1.0)[source]

Computes the spectral response of a high-pass filter.

\[\mu_s(\lambda) = \frac{s\lambda}{s\lambda + 1}\]

This filter attenuates low-frequency (small eigenvalue) components while preserving high-frequency structure.

Parameters:
  • x (ndarray) – Input array of eigenvalues \(\lambda\).

  • scale (float, default: 1.0) – The scale parameter \(s\). Larger values shift the cutoff to lower frequencies.

Returns:

The filter’s gain at each point in x.

Return type:

ndarray

Band-Pass

bandpass(x, scale=1.0, order=1)[source]

Computes the spectral response of a band-pass filter.

This wavelet generating kernel is based on the SGWT design:

\[\Psi_s(\lambda) = \left( \frac{4\lambda/s}{(\lambda + 1/s)^2} \right)^n\]

where \(n\) is the filter order. The filter peaks at \(\lambda = 1/s\) with maximum gain of 1, and satisfies the admissibility condition \(\Psi(0) = 0\).

Parameters:
  • x (ndarray) – Input array of eigenvalues \(\lambda\).

  • scale (float, default: 1.0) – The scale parameter \(s\). The filter peaks at \(\lambda = 1/s\).

  • order (int, default: 1) – The filter order \(n\). Higher orders produce narrower bandwidths.

Returns:

The filter’s gain at each point in x.

Return type:

ndarray

Gaussian Wavelet

gaussian_wavelet(time, a=1, b=0, w0=1)[source]

Compute a Morlet-like Gaussian wavelet.

Generates a complex-valued wavelet with Gaussian envelope and oscillatory carrier, normalized for continuous wavelet transform applications.

The analytical form is:

\[\psi_{a,b}(t) = C e^{-\frac{(t')^2}{2}} \left( e^{i \omega_0 t'} - e^{-\frac{\omega_0^2}{2}} \right)\]

where \(t' = (t-b)/a\) and the normalization constant is \(C = (\Delta t / a) \pi^{-1/4}\). The term \(e^{-\omega_0^2 / 2}\) ensures the wavelet has zero mean.

Parameters:
  • time (ndarray) – Time vector of shape (n_time,) in seconds. Must have at least 2 elements for timestep inference.

  • a (float, default 1) – Scale parameter (temporal dilation). Larger values produce wider wavelets centered on lower frequencies.

  • b (float, default 0) – Translation parameter (center time in seconds).

  • w0 (float, default 1) – Central angular frequency in rad/s. Default of 2*np.pi gives 1 Hz center frequency.

Returns:

Complex-valued wavelet of shape (n_time,), normalized by dt/a.

Return type:

ndarray

Examples

>>> import numpy as np
>>> from sgwt.functions import gaussian_wavelet
>>> t = np.linspace(0, 10, 1000)
>>> psi = gaussian_wavelet(t, a=0.5, b=5.0, w0=2*np.pi)