Generated reference › Spectral Kurtosis — Control Systems/Spectral Measurements
kind: generated#block#control-systems-spectral-measurements

Spectral Kurtosis — Control Systems/Spectral Measurements

K

Control_Systems/Spectral_Measurements/Spectral_Kurtosis · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Spectral Kurtosis

Control Systems / Spectral Measurements

Reports, for each frequency bin, how non-Gaussian a scalar stream is there. Over K short-time frames of the sliding window, with P the frame's power at that bin, SK = (K+1)/(K−1)·mean(P²)/mean(P)² − 2. This is the engine of MATLAB's pkurtosis, transcribed from computeSpectralKurtosis.

It reads near 0 at every bin of a stationary Gaussian process, and large and positive at bins carrying transients or impulsive content – which is what makes it the standard first look for a bearing fault, and what a Kurtogram is built out of. It says nothing about how much power a bin carries: the ratio is unchanged if the whole spectrum is scaled. Band Power is what reports that.

Ports

  • x – the stream, a scalar. The block does its own framing, so samples arrive one at a time.
  • SK – the kurtosis, a column of L/2 + 1 entries: one per frequency bin from DC to Nyquist, where L is the frame length. Entry m is the bin at m/L cycles per sample.

Parameters

  • Frame Length – L, the transform length, an even whole number from 4 to 32. It sets the frequency resolution and the number of output bins.
  • Frames – K, how many frames the kurtosis is taken over, from 2 to 8. One is refused: MATLAB drops the bias correction below two frames, and a single frame has no dispersion to measure.
  • Frame Overlap – how far the frames overlap.
    • None (0%) – the hop is L.
    • Half (50%) – the hop is L/2. This block's default.
    • Three quarters (75%) – the hop is L/4; needs L divisible by four.
    The window the block holds is W = L + (K−1)·hop samples long.
  • Window – the taper applied to each frame: Hamming, Hann or Rectangular. Both tapers are the symmetric form, which is what hamming and hann return unless asked otherwise.
  • Edge Bins – what happens at the ends of the axis.
    • Zero near DC and Nyquist – the first two and the last two bins report exactly 0, which is computeSpectralKurtosis's own rule. The default.
    • Keep every bin – every bin is computed. Use it to compare against a textbook definition; the edge bins of a short transform are dominated by leakage and are not a measurement.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. Every transform is a fixed weighted sum of window taps whose weights are computed once at export time, so no emitted core contains a sine, a cosine or a loop over data. A masked edge bin is emitted as a literal zero with no arithmetic at all, so the two Edge Bins settings produce structurally different cores rather than the same core with a different number in it. Nothing is exposed as a tunable parameter: changing the window or the framing changes the whole coefficient table.

The three HDL targets are simulation-only: they carry the arithmetic in real and quantize only at the port boundary. The answer is a ratio of two run-time quantities, one of them a sum of fourth powers, which does not belong in a Q16.16 datapath. VHDL additionally carries each bin in an emitted function, because a clocked process here has no place to keep a bin's running sums.

Simulink bridge

No equivalent (Support::None), so nothing crosses in either direction, and no parity testbench is owed. Measured rather than assumed: pkurtosis is a Signal Processing Toolbox function, that toolbox ships no Simulink library at all, and a find_system sweep at depth 6 with LookUnderMasks over 26 library roots – 8001 blocks – matched no kurtosis block anywhere. No configuration of it crosses either, including "Sampling Time (s)", which has no counterpart to be written to. Code export verification still covers the block across all ten languages.

Notes

  • Stateful and inherently discrete: one shift register of W samples, advanced once per sample (setDiscreteOnlyBlock(true)). The first W−1 samples of a run are read against a zero-prefilled window, as every sliding-window block here is.
  • The framing is this block's, not pspectrum's. Given a signal, pkurtosis builds its spectrogram with an automatically chosen window at 80 % overlap; that is a whole estimator and not something a wire carries. What is reproduced here exactly is the kurtosis engine – verified bit for bit against computeSpectralKurtosis at K = 2 and K = 3 – over frames this block cuts itself.
  • The bias correction is part of the answer. (K+1)/(K−1) is 3 at K = 2 and 9/7 at K = 8, so a reading that dropped it is up to a whole unit low on a quantity whose interesting values are a few units.
  • It is scale-invariant. The ratio is unchanged by any positive scaling of the spectrum, which is why the transform needs no normalization and why the block reports nothing about power.
  • A silent bin answers −2, not a NaN: the denominator is floored, and 0/floor gives the −2 the formula's constant leaves behind.
  • Related blocks. Spectral Entropy asks how SPREAD the power is in one instant; this asks how IMPULSIVE it is over several. Both are in this family and neither implies the other.

Code facts#

FactValue
registered typeControl_Systems/Spectral_Measurements/Spectral_Kurtosis
familyControl_Systems/Spectral_Measurements
solver environment classICoreBlock_0_Control_Systems_1_Spectral_Measurements_2_Spectral_Kurtosis
sourcesrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Spectral_Measurements/Spectral_Kurtosis/ICoreBlock_0_Control_Systems_1_Spectral_Measurements_2_Spectral_Kurtosis.cpp
headersrc/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Spectral_Measurements/Spectral_Kurtosis/ICoreBlock_0_Control_Systems_1_Spectral_Measurements_2_Spectral_Kurtosis.h
default size on canvas150 × 80 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoublex
2outICoreDoubleSK

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Frame Length8—
Frames4—
Frame OverlapNone (0%)%~%Half (50%)%~%Three quarters (75%)~~Half (50%)—
WindowHamming%~%Hann%~%Rectangular~~Hamming—
Edge BinsZero near DC and Nyquist%~%Keep every bin~~Zero near DC a…—

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path—
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): no Simulink equivalent. pkurtosis is a Signal Processing Toolbox MATLAB function, not a block; that toolbox ships no Simulink library, and a find_system sweep of 8001 blocks across 26 library roots at depth 6 with LookUnderMasks carries no spectral-kurtosis block

Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Spectral Kurtosis -- MATLAB's pkurtosis over a sliding window, bin by bin. SK(m) = (K+1)/(K-1) * mean_s(P_ms^2) / mean_s(P_ms)^2 - 2, P_ms = |X_s(m)|^2

ONE COEFFICIENT TABLE, TEN IDENTICAL BODIES. Every transform is a fixed weighted sum of window taps -- coefficient (m, n) is w(n)*cos(2*pi*m*n/L) for the real part and -w(n)*sin(...) for the imaginary one -- so the table is built once when the configuration is read and no emitted core contains a sine, a cosine, or a loop over data.

⚠ WHAT IS TRANSCRIBED HERE IS THE KURTOSIS ENGINE, NOT pkurtosis's SEGMENTATION, and the difference is stated rather than blurred. computeSpectralKurtosis is four lines and this block reproduces them EXACTLY -- verified against the installed R2026a by calling that internal directly on a power spectrogram this side chose, at K = 3 and K = 2:

P = [0.9 1.7 0.4; 2.2 0.3 1.1; 0.5 0.8 2.4; 1.3 1.9 0.2; 0.7 0.6 1.5] K = 3 -> 0.57333333333333325 0.842592592592593 0.91453615777940067 0.77162629757785384 0.37244897959183687 K = 2 -> 1.2840236686390529 2.732800000000001 1.1597633136094676 1.1054687499999991 1.0177514792899416

reproduced bit for bit, relative error exactly 0, on both. What is NOT reproduced is how MATLAB gets P from a signal: pkurtosis(x) calls pspectrum(..., 'spectrogram', 'OverlapPercent', 80) with an automatically chosen window, which is a whole estimator with its own conventions and nothing a wire can carry. This block cuts its own frames, with the length, the count, the overlap and the taper all configured, and says so.

⚠ THE BIAS CORRECTION IS PART OF THE ANSWER. (K+1)/(K-1) is 3 at K = 2 and 9/7 at K = 8 -- the whole useful range for a sliding window -- so a core that dropped it reads up to a whole unit low, on a quantity whose interesting values are a few units. MATLAB applies it whenever K >= 2, and K < 2 is refused here rather than allowed to take the uncorrected branch.

⚠ THE FOUR EDGE BINS ARE FORCED TO ZERO, and which four is decided by the configuration. computeSpectralKurtosis zeroes f <= fs/window and f >= fs/2 - fs/window; on an L-point transform with bin m at m*fs/L that is m <= 1 and m >= L/2 - 1, i.e. the first two bins and the last two. Measured on an 8-point transform at fs = 100: bins 0, 1, 3 and 4 of the five are zeroed and only bin 2 survives. They are emitted as a literal zero with NO arithmetic rather than computed and discarded, which is a structurally different core -- so the unmasked form is a mode and not a hidden default.

⚠ THE NORMALISATION OF THE TRANSFORM CANCELS. mean(P^2)/mean(P)^2 is homogeneous of degree zero in P, so the window power and any scale factor on the transform divide out. That is

Sample results#

Spectral Kurtosis — Step: 0 -> 1 at t = 1 sSpectral Kurtosis — Step: 0 -> 1 at t = 1 s00.51012345t (s)in ICoreDouble-Out-0out ICoreDouble-Out-0 [5x1] entry 0

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)0 … 0
rampRamp: slope 1 from t = 00 … 0
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias0 … 0
tableRepeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample0 … 0

Plotted: step — Step: 0 -> 1 at t = 1 s

Category dynamic · sample time 0.1 · 60 steps · commit 3c100aff6f27235305db4ad4d572f32e342718ad · produced by docsSample --out <folder> --blocks Spectral_Kurtosis --steps 60 · data docs/generated/samples/Control_Systems__Spectral_Measurements__Spectral_Kurtosis.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).