Main Content

spectralKurtosis

Spectral kurtosis for signals and spectrograms

Description

kurtosis = spectralKurtosis(x,f) returns the spectral kurtosis of the signal, x, over time. How the function interprets x depends on the shape of f.

example

kurtosis = spectralKurtosis(x,f,Name=Value) specifies options using one or more name-value arguments.

example

[kurtosis,spread,centroid] = spectralKurtosis(___) returns the spectral spread and spectral centroid. You can specify an input combination from any of the previous syntaxes.

[___,threshold] = spectralKurtosis(___,ConfidenceLevel=p) returns the spectral kurtosis threshold using the confidence level p. threshold represents the range within which the spectral kurtosis indicates that the input signal is Gaussian and stationary. (since R2024b)

example

spectralKurtosis(___) with no output arguments plots the spectral kurtosis.

  • If the input is in the time domain, the spectral kurtosis is plotted against time.

  • If the input is in the frequency domain, the spectral kurtosis is plotted against frame number.

example

Examples

collapse all

Create a chirp signal with white Gaussian noise and calculate the kurtosis using default parameters.

fs = 1000;
t = (0:1/fs:10)';
f1 = 300;
f2 = 400;
x = chirp(t,f1,10,f2) + randn(length(t),1);

kurtosis = spectralKurtosis(x,fs);

Plot the spectral kurtosis against time.

spectralKurtosis(x,fs)

Figure contains an axes object. The axes object with xlabel Frame, ylabel Kurtosis contains an object of type line.

ans = 311×1

    1.8917
    2.0148
    2.0072
    2.3115
    2.5388
    2.6767
    3.5465
    2.6520
    1.8541
    1.9612
      ⋮

Create a chirp signal with white Gaussian noise and then calculate the spectrogram using the stft function.

fs = 1000;
t = (0:1/fs:10)';
f1 = 300;
f2 = 400;
x = chirp(t,f1,10,f2) + randn(length(t),1);

[s,f] = stft(x,fs,FrequencyRange="onesided");
s = abs(s).^2;

Calculate the kurtosis of the spectrogram over time.

kurtosis = spectralKurtosis(s,f);

Plot the spectral kurtosis against the frame number.

spectralKurtosis(s,f)

Figure contains an axes object. The axes object with xlabel Frame, ylabel Kurtosis contains an object of type line.

ans = 309×1

    2.1493
    2.1535
    2.2603
    2.7306
    2.9952
    3.4491
    3.0367
    1.9098
    2.1831
    3.1929
      ⋮

Create a chirp signal with white Gaussian noise.

fs = 1000;
t = (0:1/fs:10)';
f1 = 300;
f2 = 400;
x = chirp(t,f1,10,f2) + randn(length(t),1);

Calculate the kurtosis of the power spectrum over time. Calculate the kurtosis for 50 ms Hamming windows of data with 25 ms overlap. Use the range from 62.5 Hz to fs/2 for the kurtosis calculation.

kurtosis = spectralKurtosis(x,fs, ...
                      Window=hamming(round(0.05*fs)), ...
                      OverlapLength=round(0.025*fs), ...
                      Range=[62.5,fs/2]);

Plot the kurtosis against time.

spectralKurtosis(x,fs, ...
              Window=hamming(round(0.05*fs)), ...
              OverlapLength=round(0.025*fs), ...
              Range=[62.5,fs/2])

Figure contains an axes object. The axes object with xlabel Frame, ylabel Kurtosis contains an object of type line.

ans = 399×1

    2.4705
    1.7254
    2.6380
    2.0368
    1.7424
    3.9148
    2.8702
    4.9501
    3.2581
    3.0039
      ⋮

Plot the spectral kurtosis of a chirp signal in white noise, and see how the nonstationary non-Gaussian regime can be detected. Explore the effects of changing the confidence level.

Create a chirp signal, add white Gaussian noise, and plot.

fs = 1000;
t = 0:1/fs:10;
f1 = 300;
f2 = 400;

xc = chirp(t,f1,10,f2);
x = xc + randn(1,length(t));

plot(t,x)
title('Chirp Signal with White Gaussian Noise')

Figure contains an axes object. The axes object with title Chirp Signal with White Gaussian Noise contains an object of type line.

Compute and plot the spectral kurtosis of the signal.

[S,F] = pspectrum(x,fs,"spectrogram", ...
    FrequencyResolution=fs/winlen(length(x)),OverlapPercent=80);

[sK95,~,~,thresh95] = spectralKurtosis(S,F,Scaled=false);

plot(F,sK95)
yline(thresh95*[-1 1])
grid
xlabel("Frequency (Hz)")
title("Spectral Kurtosis of Chirp Signal with White Gaussian Noise")

Figure contains an axes object. The axes object with title Spectral Kurtosis of Chirp Signal with White Gaussian Noise, xlabel Frequency (Hz) contains 3 objects of type line, constantline.

The plot shows a clear extended excursion from 300–400 Hz. This excursion corresponds to the signal component that represents the nonstationary chirp. The area between the two horizontal red-dashed lines represents the zone of probable stationary and Gaussian behavior, as defined by the 0.95 confidence interval. Any kurtosis points falling within this zone are likely to be stationary and Gaussian. Outside of the zone, kurtosis points are flagged as nonstationary or non-Gaussian. Below 300 Hz, there are a few additional excursions slightly above the above the zone threshold. These excursions represent false positives, where the signal is stationary and Gaussian, but because of the noise, has exceeded the threshold.

Investigate the impact of the confidence level by changing it from the default 0.95 to 0.85.

[sK85,~,~,thresh85] = spectralKurtosis(S,F,Scaled=false,ConfidenceLevel=0.85);

plot(F,sK85)
yline(thresh85*[-1 1])
grid
xlabel("Frequency (Hz)")
title("Spectral Kurtosis of Chirp Signal with Noise at Confidence Level of 0.85")

Figure contains an axes object. The axes object with title Spectral Kurtosis of Chirp Signal with Noise at Confidence Level of 0.85, xlabel Frequency (Hz) contains 3 objects of type line, constantline.

The lower confidence level implies more sensitive detection of nonstationary or non-Gaussian frequency components. Reducing the confidence level shrinks the thresh-delimited zone. Now the low-level excursions — false alarms — have increased in both number and amount. Setting the confidence level is a balancing act between achieving effective detection and limiting the number of false positives.

Compare the zone width for the two cases.

thresh = [thresh95 thresh85]
thresh = 1×2

    0.3578    0.2628

function y = winlen(x)
    wdiv = 2.^[1 3:7];
    y = ceil(x/wdiv(find(x < 2.^[6 11:14 Inf],1)));
end

Input Arguments

collapse all

Input signal, specified as a vector, matrix, 3-D array or timetable. How the function interprets x depends on the shape of f.

Data Types: single | double

Sample rate or frequency vector in Hz, specified as a scalar or vector, respectively. How the function interprets x depends on the shape of f:

  • If f is not specified and x is a numeric vector or matrix, spectralKurtosis assumes x is sampled at a rate equal to 1 Hz. If f is not specified and x is a timetable, spectralKurtosis infers the sample rate from x.

  • If f is a scalar, x is interpreted as a time-domain signal, and f is interpreted as the sample rate. In this case, x must be a real vector or matrix. If x is specified as a matrix, the columns are interpreted as individual channels.

  • If f is a vector, x is interpreted as a frequency-domain signal, and f is interpreted as the frequencies, in Hz, corresponding to the rows of x. In this case, x must be a real L-by-M-by-N array, where L is the number of spectral values at given frequencies of f, M is the number of individual spectra, and N is the number of channels.

    The number of rows of x, L, must be equal to the number of elements of f.

Data Types: single | double

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: Window=hamming(256)

Note

The following name-value arguments apply if x is a time-domain signal. If x is a frequency-domain signal, only the Scaled argument applies.

Window applied in the time domain, specified as a real vector. The number of elements in the vector must be in the range [1, size(x,1)]. The number of elements in the vector must also be greater than OverlapLength. If you do not specify Window, spectralKurtosis uses a window length that splits x into eight overlapping segments.

Data Types: single | double

Number of samples overlapped between adjacent windows, specified as an integer in the range [0, size(Window,1)). If you do not specify OverlapLength, spectralKurtosis uses a value that results in 50% overlap between segments.

Data Types: single | double

Number of bins used to calculate the DFT of windowed input samples, specified as a positive scalar integer. If unspecified, FFTLength defaults to the number of elements in the Window.

Data Types: single | double

Frequency range in Hz, specified as a two-element row vector of increasing real values in the range [0, f/2].

Data Types: single | double

Spectrum type, specified as "power" or "magnitude":

  • "power" –– The spectral kurtosis is calculated for the one-sided power spectrum.

  • "magnitude" –– The spectral kurtosis is calculated for the one-sided magnitude spectrum.

Data Types: char | string

Since R2024b

Scale option, specified as a logical. This argument specifies how the spectral kurtosis is computed when x is a frequency-domain signal. If Scaled is true, spectralKurtosis returns the frequency-averaged spectral kurtosis. If Scaled is false, spectralKurtosis returns the numeric kurtosis of the signal spectrogram.

This argument applies if x is a time-domain signal or if x is a frequency-domain signal.

Data Types: logical

Since R2024b

Confidence level used to determine whether the input signal is likely to be Gaussian and stationary, specified as a numeric scalar value from 0 to 1. This argument influences the threshold range where the spectral kurtosis value indicates a Gaussian and stationary signal. The confidence level therefore provides a detection-sensitivity tuning parameter. Kurtosis values outside of this range indicate non-Gaussian or nonstationary behavior. This argument applies only if you are returning threshold.

Data Types: single | double

Output Arguments

collapse all

Spectral kurtosis, returned as a scalar, vector, or matrix. Each row of kurtosis corresponds to the spectral kurtosis of a window of x. Each column of kurtosis corresponds to an independent channel.

Spectral spread, returned as a scalar, vector, or matrix. Each row of spread corresponds to the spectral spread of a window of x. Each column of spread corresponds to an independent channel.

Spectral centroid in Hz, returned as a scalar, vector, or matrix. Each row of centroid corresponds to the spectral centroid of a window of x. Each column of centroid corresponds to an independent channel.

Since R2024b

Spectral kurtosis band size for stationary Gaussian behavior, returned as a numeric scalar representing the thickness of the band centered at zero, given the confidence level specified using ConfidenceLevel. Excursions outside the threshold-delimited band indicate possible nonstationary or non-Gaussian behavior. The confidence level directly influences the thickness of the band and the sensitivity of the results.

More About

collapse all

Spectral Kurtosis

Spectral kurtosis (SK) is a statistical tool that can indicate and pinpoint nonstationary or non-Gaussian behavior in the frequency domain, by taking:

  • Small values at frequencies where only stationary Gaussian noise is present

  • High positive values at frequencies where transients occur

This capability makes SK a powerful tool for detecting and extracting signals associated with faults in rotating mechanical systems. On its own, SK can identify features or conditional indicators for fault detection and classification. As preprocessing for other tools such as envelope analysis, SK can supply key inputs such as optimal band [1], [2],.

The spectral kurtosis, or K(f), of a signal x(t) can be computed based on the short-time Fourier transform (STFT) of the signal, S(t,f):

S(t,f)=x(τ)w(τt)ej2πfτdτ,

where w(t) is the window function used in the STFT. K(f) is calculated as

K(f)=|S(t,f)|4t|S(t,f)|2t22, f0,

where 〈·〉t is the time-average operator.

If the signal x(t) contains only stationary Gaussian noise, then K(f) at each frequency f has an asymptotic normal distribution with 0 mean and variance 4/M, where M is the number of elements along the time axis in S(t,f). Hence, a statistical threshold sα given a confidence level α is

sα=Φ1(α)2M,

where Φ1(α)=2erf1(2α1) is the quantile function of the standard normal distribution.

It is important to note that the STFT window length Nw directly drives frequency resolution, which is fs/Nw, where fs is the sample rate. The window size must be shorter than the spacing between transient impulses but longer than the individual transient impulses.

Algorithms

The spectral kurtosis is calculated as described in [3]:

kurtosis=k=b1b2(fkμ1)4sk(μ2)4k=b1b2sk

where

  • fk is the frequency in Hz corresponding to bin k.

  • sk is the spectral value at bin k.

  • b1 and b2 are the band edges, in bins, over which to calculate the spectral skewness.

  • μ1 is the spectral centroid, calculated as described by the spectralCentroid (Audio Toolbox) function.

  • μ2 is the spectral spread, calculated as described by the spectralSpread (Audio Toolbox) function.

References

[1] Antoni, J. "The Spectral Kurtosis: A Useful Tool for Characterising Non-Stationary Signals." Mechanical Systems and Signal Processing. Vol. 20, Issue 2, 2006, pp. 282–307.

[2] Antoni, J., and R. B. Randall. "The Spectral Kurtosis: Application to the Vibratory Surveillance and Diagnostics of Rotating Machines." Mechanical Systems and Signal Processing. Vol. 20, Issue 2, 2006, pp. 308–331.

[3] Peeters, G. "A Large Set of Audio Features for Sound Description (Similarity and Classification) in the CUIDADO Project." Technical Report; IRCAM: Paris, France, 2004.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

Version History

Introduced in R2019a

expand all

See Also

| | (Audio Toolbox) | | | (Audio Toolbox)

Topics