packages

signal::spectral::analytic

The analytic signal by the FFT (Marple 1999, "Computing the discrete-time analytic signal via FFT"): keep DC and Nyquist, double the positive frequencies, drop the negative ones.

Functions

hilbertSource

pub fn hilbert(x: some RealSamples, n: usize? = none) throws (SignalError) -> Vector<Complex<f64>>

The analytic signal x + i H(x) of a real x (H the Hilbert transform), zero-padded or cut to n samples when given. As SciPy's hilbert: its real part is x, its modulus the envelope.

nabi
use core::array::Vector;

let x: Vector<f64> = [1, 0, -1, 0];
let z = try signal::spectral::hilbert(x);
println(signal::imag(z)); // [0.0, 1.0, 0.0, -1.0]

envelopeSource

pub fn envelope(x: some RealSamples, n: usize? = none) throws (SignalError) -> Vector<f64>

The amplitude envelope |hilbert(x)|.

nabi
use core::array::Array;

let x = Array::from_fn([64], |i: [usize; 1]| -> f64 { 3.0 * (f64::PI * (i[0] as f64) / 4.0).cos() });
println(try signal::spectral::envelope(x)[10]); // 3.0 (to rounding)