主要内容

plotHistogram

Plot histogram of anomaly scores and detection threshold for statistical process control (SPC) anomaly detector

Since R2025a

Description

Add-On Required: This feature requires the Time Series Anomaly Detection for MATLAB add-on.

plotHistogram(detector,data1) plots computes the anomaly scores for the SPC detector detector using the data in data1, and plots a histogram of the scores along with the threshold in detector.threshold.

Use this syntax, for example, when you have trained a detector using the normal data in data1, and you want to examine the score distribution and the threshold placement.

For an example of using plotHistogram as part of the detector development workflow, see Train and Test TCN Anomaly Detector.

plotHistogram(detector,data1,data2) plots the histograms for two sets of data, data1 and data2, together in the same figure.

Use this syntax, for example, when you have both normal data and test data and you want to view the histogram of the associated anomaly scores together. You can use this syntax without running detect first.

plotHistogram(___,Name=Value) sets additional options using one or more name-value arguments.

Input Arguments

collapse all

Statistical process control anomaly detector, specified as a TimeSeriesIForestDetector object.

Time series data for computing the first or only set of anomaly scores to plot, specified as a matrix, a timetable, or a cell array. Typically, data1 contains the training data that was used for training the anomaly detector and consists of only normal data, with no known anomalies or abnormal data.

When data1 contains m sets of signals, each of which contain n = detector.NumChannels channels, the possible formats are these:

  • n-column matrix that consists of a single multichannel signal (m=1).

  • Cell array with m cells that each contain a matrix that has NumChannels columns.

  • Timetable that contains a single multichannel signal , arranged in one of two possible ways.

    • The n channels are distributed in the columns of a matrix that the timetable contains in a single variable

    • The n channels are represented by n timetable variables that each contain a vector.

    In either case, the timetable must contain finite, increasing, and uniformly sampled time values.

Time series data for computing the second set of anomaly scores to plot, specified as a matrix, a cell array, or a timetable. Typically, data2 consists of test data, and can contain a mix of abnormal and normal data.

When data2 contains m sets of signals, each of which contain n = detector.NumChannels channels, the possible formats are these:

  • n-column matrix that consists of a single multichannel signal (m=1).

  • Cell array with m cells that each contain a matrix that has NumChannels columns.

  • Timetable that contains a single multichannel signal , arranged in one of two possible ways.

    • The n channels are distributed in the columns of a matrix that the timetable contains in a single variable

    • The n channels are represented by n timetable variables that each contain a vector.

    In either case, the timetable must contain finite, increasing, and uniformly sampled time values.

Version History

Introduced in R2025a