statelevels

State-level estimation for bilevel waveform with histogram method

Syntax

LEVELS = statelevels(X)
LEVELS = statelevels(X,NBINS)
LEVELS = statelevels(X,NBINS,METHOD)
[LEVELS,HISTOGRAM] = statelevels(...)
[LEVELS,HISTOGRAM,BINLEVELS] = statelevels(...)
statelevels(...)

Description

LEVELS = statelevels(X) estimates the low- and high-state levels in the bilevel waveform, X, using the histogram method. See Algorithms.

LEVELS = statelevels(X,NBINS) specifies the number of bins to use in the histogram as a positive scalar. If unspecified, NBINS defaults to 100.

LEVELS = statelevels(X,NBINS,METHOD) estimates state levels using the mean or mode of the subhistograms. Valid entries for METHOD are 'mean' or 'mode'. METHOD defaults to 'mode'. See Algorithms.

[LEVELS,HISTOGRAM] = statelevels(...) returns the histogram, HISTOGRAM, of the values in X.

[LEVELS,HISTOGRAM,BINLEVELS] = statelevels(...) returns the centers of the histogram bins.

statelevels(...) displays a plot of the signal and the corresponding computed histogram.

Input Arguments

X

Bilevel waveform. X is a real-valued row or column vector.

NBINS

Number of histogram bins

Default: 100

METHOD

State-level estimation method in the subhistograms. METHOD is a string indicating the statistic to use for the estimation of the low- and high-state levels. Valid entries for METHOD are 'mode' or 'mean'. See Algorithms.

Default: 'mode'

Output Arguments

LEVELS

Levels of low and high states. LEVELS is a 1-by-2 row vector of state levels estimated by the histogram method. The first element of LEVELS is the low-state level. The second element of LEVELS is the high-state level.

HISTOGRAM

Histogram counts (frequencies). HISTOGRAM is a column vector with NBINS elements containing the number of data values in each histogram bin.

BINLEVELS

Histogram bin centers. BINLEVELS is a column vector containing the bin centers for the histogram counts in HISTOGRAM.

Examples

expand all

Display State Levels and Subhistograms

Estimate the low- and high-state levels of 2.3 V underdamped clock data. Plot the data with the estimated state levels and subhistograms.

load('clockex.mat', 'x');
statelevels(x);

State Levels with 100 Bins and Modes of Subhistograms

Estimate the low and high-state levels of 2.3 V underdamped clock data sampled at 4 MHz.

Use the default number of bins and modes of the subhistograms to estimate the state levels. Plot the clock data with the lines indicating the estimated low and high-state levels.

load('clockex.mat', 'x', 't');
LEVELS = statelevels(x);
plot(t,x);
hold on;
plot(t,LEVELS(1).*ones(length(x)),'r--');
plot(t,LEVELS(2).*ones(length(x)),'r--');

State Levels Using Means of Subhistograms

Estimate the low and high-state levels of 2.3 V underdamped clock data sampled at 4 MHz.

Use the default number of bins and means of the subhistograms to estimate the state levels. Plot the clock data with the lines indicating the estimated low and high-state levels.

load('clockex.mat', 'x', 't');
LEVELS = statelevels(x,1e3,'mean');

Histogram Counts and Histogram Bin Centers

Estimate the low- and high-state levels of 2.3 V underdamped clock data sampled at 4 MHz. Return the histogram counts and histogram bin centers used in the histogram method.

load('clockex.mat', 'x', 't');
[LEVELS,HISTOGRAM,BINLEVELS] = statelevels(x);

More About

expand all

State

A particular level, which can be associated with an upper- and lower-state boundary. States are ordered from the most negative to the most positive. In a bilevel waveform, the most negative state is the low state. The most positive state is the high state.

State-Level Tolerances

Each state level can have associated lower- and upper-state boundaries. These state boundaries are defined as the state level plus or minus a scalar multiple of the difference between the high state and low state. To provide a useful tolerance region, the scalar is typically a small number such as 2/100 or 3/100. In general, the α% tolerance region for the low state is defined as

S1±α100(S2S1)

where S1 is the low-state level and S2 is the high-state level. Replace the first term in the equation with S2 to obtain the α% tolerance region for the high state.

The following figure illustrates lower and upper 2% state boundaries (tolerance regions) for a positive-polarity bilevel waveform. The red dashed lines indicate the estimated state levels.

Algorithms

statelevels uses the histogram method to estimate the states of a bilevel waveform. The histogram method is described in [1]. To summarize the method:

  1. Determine the maximum and minimum amplitudes and amplitude range of the data.

  2. For the specified number of histogram bins, determine the bin width as the ratio of the amplitude range to the number of bins.

  3. Sort the data values into the histogram bins.

  4. Identify the lowest-indexed histogram bin, ilow, and highest-indexed histogram bin, ihigh, with nonzero counts.

  5. Divide the histogram into two subhistograms.

    The indices of the lower histogram bins are ilowi ≤ 1/2(ihighilow).

    The indices of the upper histogram bins are ilow + 1/2(ihighilow) ≤ iihigh.

  6. Compute the state levels by determining the mode or mean of the lower and upper histograms.

References

[1] IEEE® Standard on Transitions, Pulses, and Related Waveforms, IEEE Standard 181, 2003, pp. 15–17.

Was this topic helpful?