# Spacing of extreme events

The DN_OutlierInclude features measure the relative spacing of extreme events through the time series
catch22 contains two features based on the `DN_OutlierInclude` function in hctsa:
• `DN_OutlierInclude_p_001_mdrmd` (the `mdrmd` output from running `DN_OutlierInclude(x_z,'pos',0.01)` in hctsa)
• `DN_OutlierInclude_n_001_mdrmd` (the `mdrmd` output from running`DN_OutlierInclude(x_z,'neg',0.01)` in hctsa).

### What it does

These features involve the following steps:
1. 1.
z-score the input time series.
2. 2.
Initialize an equally spaced set of increments, from zero to the maximum value of the time series, in the case of `DN_OutlierInclude_p_001_mdrmd` (or from 0 to the minimum value of the time series in the case of `DN_OutlierInclude_n_001_mdrmd`). In this way, a set of increasingly 'extreme' deviations from the mean (either deviations above-the-mean or below-the-mean) are analyzed across the loop in Step (3).
3. 3.
At each threshold set in Step (2):
1. 1.
Determine the time points in which the time series is 'over-threshold'.
2. 2.
Compute the median index of all such over-threshold time points, as `rmd` .
3. 3.
For interpretation, and to appropriately compare time series of different lengths, we then linearly re-scale `rmd` such that a median right in the middle of the time series, at index `N/2`, maps to 0, a value at the end of the time series, at index `N`, maps to 1, and a value at the start of the time series, index `1`, maps to a -1.
4. 4.
The final statistic returns the median of all values of `rmd` values across all values of the threshold, as the output statistic.

### What it measures

These statistics measure whether over-threshold events (either positive or negative deviations from the mean) tend to be positioned relative near the start of the time series (output values near -1), approximately equally likely to be anywhere through the time series (output values near 0), or more likely to be near the end of the time series (output values near 1). These features thus capture something related to the stationarity of over-threshold events.
To give an intuition, below we plot some examples of how `rmd` at a fixed threshold (80% the maximum positive deviation) for the case of `DN_OutlierInclude_p_001_mdrmd`. (But note that the full statistic takes the median of `rmd` across a range of thresholds, as described above).
• Time series, that have extreme events (red dots, relative to the threshold, shown as a dashed red line) distributed similarly across time, will yield values close to zero for this statistic (vertical blue line). For example these:
• Time series like these, for which large deviations from the mean tend to occur nearer to the end of the time series, will have values closer to 1:
• And time series like these, for which large deviations from the mean tend to occur nearer the start of the time series, will have values nearer to -1: