πŸ“Š

Histogram

Sinks
Run the live example Free Β· no sign-up Β· runs in your browser

The Histogram block accumulates incoming continuous or discrete signal samples over the course of a simulation run and renders their empirical probability density or frequency distribution as an interactive bar chart. Incoming samples are sorted into discrete bins spanning a user-defined or automatically detected range. It is an essential analytical tool for stochastic process evaluation, sensor noise characterization, Monte Carlo simulation yield analysis, and verification of Gaussian or uniform statistical properties.

Mathematical Model

Given a stream of NN recorded scalar samples {u1,u2,…,uN}\{u_1, u_2, \dots, u_N\} over simulation time [0,t][0, t], the range interval [xmin⁑,xmax⁑][x_{\min}, x_{\max}] is divided into BB contiguous bins:

Ij=[xj,xj+1),j=0,1,…,Bβˆ’1I_j = [x_j, x_{j+1}), \quad j = 0, 1, \dots, B-1

where the bin width ww is determined by binMode:

w={xmaxβ‘βˆ’xmin⁑B,binMode=countbinWidth,binMode=width2β‹…IQR⁑(u)β‹…Nβˆ’1/3,binMode=autoΒ (Freedman-Diaconis)w = \begin{cases} \frac{x_{\max} - x_{\min}}{B}, & \text{binMode} = \text{count} \\ \text{binWidth}, & \text{binMode} = \text{width} \\ 2 \cdot \operatorname{IQR}(u) \cdot N^{-1/3}, & \text{binMode} = \text{auto (Freedman-Diaconis)} \end{cases}

The count cjc_j for each bin IjI_j is evaluated as:

cj=βˆ‘k=1N1Ij(uk)c_j = \sum_{k=1}^N \mathbf{1}_{I_j}(u_k)

where 1Ij(u)\mathbf{1}_{I_j}(u) is the indicator function. The normalized empirical probability density estimate f^(x)\hat{f}(x) for bin jj is:

f^(x)=cjNβ‹…wforΒ x∈Ij\hat{f}(x) = \frac{c_j}{N \cdot w} \quad \text{for } x \in I_j

When rangeMode = "auto", xmin⁑x_{\min} and xmax⁑x_{\max} expand dynamically to enclose all observed samples. When rangeMode = "manual", samples outside [vmin⁑,vmax⁑][v_{\min}, v_{\max}] are counted in the boundary bins.

Inputs & Outputs

Direction ID Label Type Status
→ In in Input array Required

Parameters

Parameters Label Type Default Description
rangeMode Range select auto Auto fits the axis to the data; Manual uses the Min/Max below.
minValue Min Value number -5 Lower bound (Manual range only).
maxValue Max Value number 5 Upper bound (Manual range only).
binMode Binning select count How bins are sized: a fixed number, a fixed step width, or auto.
bins Bin count number 20 Number of bins (Bin count mode).
binWidth Bin width number 1 Width/step of each bin (Fixed width mode).

Usage Examples

Example 1: Inertial Measurement Unit (IMU) Accelerometer Noise Characterization

Validating sensor measurement noise on an industrial IMU. Routing the output of an analog accelerometer channel under zero-motion conditions into a Histogram block with rangeMode = "auto" and binMode = "count" with bins = 30. Over a 10-second simulation run, observing the resulting bell curve allows engineers to confirm Gaussian normality, measure standard deviation Οƒ\sigma, and check for bias asymmetry.

Example 2: Monte Carlo Tolerance Sweep Yield Analysis

Evaluating closed-loop settling time variability across random manufacturing component tolerances. Injecting parameter variations using a RandomNumber block and routing the resulting performance metric to a Histogram with rangeMode = "manual", minValue = 0.0, maxValue = 2.0 s, and binWidth = 0.1 s. The distribution reveals whether 99%99\% of units settle within target specifications.

Remarks & Best Practices

  • Accumulative Sink Node: Unlike instantaneous scopes, the Histogram accumulates all samples from simulation start. As run duration increases, the empirical histogram converges toward the true underlying probability density function.
  • Range Clamping Behavior: In manual mode, outliers falling outside [vmin⁑,vmax⁑][v_{\min}, v_{\max}] are accumulated into the leftmost and rightmost boundary bins rather than being discarded.
  • Auto-Binning with Freedman-Diaconis: Selecting binMode = "auto" automatically balances bin resolution against sample variance, preventing oversmoothing in dense datasets or ragged noise in sparse data.
  • Zero Simulation Latency: Evaluated efficiently via fast integer bin index calculation (j=⌊(uβˆ’xmin⁑)/wβŒ‹j = \lfloor (u - x_{\min}) / w \rfloor) directly in WebAssembly.

Related Components

  • ScatterPlot: Evaluates joint statistical distributions between two independent signals.
  • RandomNumber: Generates uniform and Gaussian pseudo-random variates.
  • uPlotDisplay: Displays time-series waveforms as continuous functions of time.
  • NumericDisplay: Real-time digital LCD scalar readout.