# Extreme event timing

*catch22* contains two features based on the `DN_OutlierInclude` function in *hctsa:*

* `outlier_timing_pos`
  * This is the *hctsa* feature: `DN_OutlierInclude_p_001_mdrmd` (the `mdrmd` output from running `DN_OutlierInclude(x_z,'pos',0.01)` in *hctsa*).
* `outlier_timing_neg`
  * This is the *hctsa* feature: `DN_OutlierInclude_n_001_mdrmd` (the `mdrmd` output from running`DN_OutlierInclude(x_z,'neg',0.01)` in *hctsa*).

### What these features do

These features involve the following steps:

1. *z*-score the input time series.
2. Initialize an equally spaced set of increments, from zero to the maximum value of the time series, in the case of `outlier_timing_pos` (or from 0 to the minimum value of the time series in the case of `outlier_timing_neg`). 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. At each threshold set in Step (2):
   1. Determine the time points in which the time series is 'over-threshold'.
   2. Compute the median index of all such over-threshold time points, as `rmd` .
   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. 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 `outlier_timing_pos`. (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:

![](https://923954068-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfHFY4lvzOz3IPaA3wm%2F-MfWIHZgOtqKj3ZBao9_%2F-MfWMaISwW5gBEWr8HwP%2Fimage.png?alt=media\&token=eb109623-c752-45f1-ad8e-612832054ec2)

![](https://923954068-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfHFY4lvzOz3IPaA3wm%2F-MfWN0IaHpuuIcgX4Lgw%2F-MfWNJlEvgsvcYHEIDk0%2Fimage.png?alt=media\&token=5e180d74-4796-4885-beeb-b461b4323e1b)

* 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:

![](https://923954068-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfHFY4lvzOz3IPaA3wm%2F-MfWNRwBfFFpwzrQ8dkd%2F-MfWNbBnxwa2QHAb0qaJ%2Fimage.png?alt=media\&token=d94a3576-9c04-43af-9bad-9c5ffe550727)

![](https://923954068-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfHFY4lvzOz3IPaA3wm%2F-MfWNRwBfFFpwzrQ8dkd%2F-MfWNm9B4AZQPgB9uCiW%2Fimage.png?alt=media\&token=a8d19c0c-8c12-42a7-82e8-94fb25ba4425)

* 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:

![](https://923954068-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfHFY4lvzOz3IPaA3wm%2F-MfWNRwBfFFpwzrQ8dkd%2F-MfWNzv4_ws72HAsli2o%2Fimage.png?alt=media\&token=aa39d6f5-f518-41d4-834e-4a1b459cc33c)

![](https://923954068-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MfHFY4lvzOz3IPaA3wm%2F-MfWNRwBfFFpwzrQ8dkd%2F-MfWO5Qo9kzjhddCqaHF%2Fimage.png?alt=media\&token=7d2fabbd-3d80-4802-8fe0-7a70f9dd1bb8)
