Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Function

signal.hilbert

Computes the analytic signal of a real-valued input using an FFT-based Hilbert transform. The result is complex, with the original signal in the real part and its Hilbert transform in the imaginary part.

How it works

hilbert computes an analytic signal with an FFT: negative-frequency components are removed and positive-frequency amplitudes are doubled. The result is complex; its imaginary part is the Hilbert transform, while its real part reconstructs the real input. Processing defaults to the last axis, and N can crop or zero-pad that axis before the transform.

Syntax

scipy.signal.hilbert(x, N=None, axis=-1)

Parameters

NameTypeDescription
xarray_likeSignal data; must be real.
Nint, optionalNumber of output samples. The input is cropped or zero-padded to this length along axis. Defaults to x.shape[axis].
axisint, optionalAxis along which to perform the transformation. Defaults to -1.

Returns

ndarray — The analytic signal of x, with each one-dimensional array along axis transformed.

Key points

  • The function uses an FFT-based method to produce a complex analytic representation of a real signal.
  • Its frequency-domain construction removes negative frequencies and doubles positive-frequency amplitudes.
  • The output's imaginary component is the Hilbert transform of the supplied real-valued signal.
  • Without an axis argument, processing occurs along the final dimension.
  • When N is omitted, the number of output samples equals the input size on the selected axis.
  • Extract the Hilbert-transformed signal by taking the imaginary part of the returned array.

Common mistakes

  • The input signal must contain real-valued samples; complex-valued input is not supported by this function.
  • Supplying N changes the processed length by cropping or zero-padding along the selected axis, so the output shape along that axis becomes N.

Example: Extract envelope and phase

import numpy as np
from scipy.signal import hilbert

samples = np.sin(2 * np.pi * 5 * np.arange(100) / 100)
analytic = hilbert(samples)
envelope = np.abs(analytic)
phase = np.unwrap(np.angle(analytic))

print(envelope.shape, phase.shape)

This computes an analytic signal, then derives its amplitude envelope and unwrapped phase.

When to use it

Signal envelope extraction

Estimate instantaneous amplitude from a real waveform.

Instantaneous phase analysis

Analyze phase evolution of oscillatory data.

Multidimensional signal processing

Apply the transform independently across rows or columns of an array.

Interview questions

QWhat does scipy.signal.hilbert compute?

It returns the analytic signal obtained by zeroing negative FFT frequencies and doubling positive-frequency amplitudes. The imaginary component is the Hilbert transform of the real input.

Follow-up: How would you obtain the amplitude envelope? Take the magnitude with abs(result), which combines the real and imaginary components.

QWhat are the parameters and their defaults?

x must be real-valued signal data. N is the requested number of output samples and defaults to the input length along axis; axis defaults to -1.

Follow-up: What happens when N differs from the input length? The input is cropped or zero-padded along the selected axis before processing.

QHow does axis affect multidimensional input?

The transform operates along the last axis by default, but axis selects another dimension. For multidimensional input, each one-dimensional slice along that axis is transformed independently.

Follow-up: How can the ordinary Hilbert transform be recovered? Use np.imag(hilbert(x)); np.real(hilbert(x)) recovers the original real signal.

  • scipy.signal.hilbert2
  • scipy.signal.hilbert

Source: hilbert — SciPy v1.18.0 Manual. Checked 2026-10-15.