Skip to content
DynamicsAndNeuralSystemsPublic

About

Code for RAD in your favourite language

Resources

Stars

3 stars

Watchers

1 watching

Forks

Latest commit

 

History

27 Commits

Folders and files

Repository files navigation

Noisy trajectories relaxing toward a bifurcation

RAD: the rescaled auto-density

Paper DOI License: MIT Documentation

The rescaled auto-density (RAD) is a time-series feature for inferring the distance to criticality (DTC) of a system from a noisy recording of its activity. Unlike measures such as the standard deviation or the lag-1 autocorrelation, RAD is designed to be insensitive to uncertainty in the strength of the noise driving the system. It is computed from the shape of the two-dimensional delay embedding of the time series, as the standard deviation of the increments multiplied by the difference between the inverse spreads of the upper and lower halves of the series. This repository provides RAD in MATLAB, Python and Julia.

📖 Documentation: a summary of RAD is on the time-series analysis tools GitBook. Full details are in the paper: B. Harris, L. L. Gollo, and B. D. Fulcher, "Tracking the distance to criticality in systems with unknown noise" (arXiv:2310.14791).

Installation

RAD is a single function in a single file per language, so there is nothing to install: clone the repository (or download the file for your language) and put it where your language can find it.

Language File Requirements Setup
MATLAB RAD.m none (base MATLAB) add this folder to the path
Python RAD.py NumPy pip install numpy, then from RAD import RAD from this folder
Julia RAD.jl StatsBase.jl ] add StatsBase, then include("RAD.jl")
git clone https://github.com/DynamicsAndNeuralSystems/RAD.git

Usage

RAD takes a time series x (a vector), a delay tau (a positive integer, in units of the timestep) used for the delay embedding and for the increments, and a flag doCentre for whether to center the series at its median and take absolute values. Use the centered variant (the default) unless the series represents radial values; it is the one for signed data, as in the paper's Eq. 12. The output is a single number.

All three implementations share the signature RAD(x, tau = 1, doCentre = true). (Before this was unified, the MATLAB and Python versions took RAD(x, center, tau) and did not center by default; a call in the old order now either raises an error or, where the two orders happen to agree (such as RAD(x, 1)), gives the same result as before.)

The examples below apply RAD to the same deterministic test series of 2000 samples and give the same values in all three languages (to the printed precision):

RAD call Value
uncentered, tau = 1 0.0096
centered, tau = 1 -0.0110
centered, tau = 2 -0.0108

MATLAB

t = (1:2000)';
x = sin(0.3*t) + 0.3*cos(1.7*t) + 0.1*sin(0.011*t.^2);

RAD(x, 1, false)  % uncentered, tau = 1
RAD(x)            % centered, tau = 1 (the defaults)
RAD(x, 2)         % centered, tau = 2

Python

import numpy as np
from RAD import RAD

t = np.arange(1, 2001)
x = np.sin(0.3*t) + 0.3*np.cos(1.7*t) + 0.1*np.sin(0.011*t**2)

RAD(x, tau=1, doCentre=False)  # uncentered, tau = 1
RAD(x)                         # centered, tau = 1 (the defaults)
RAD(x, tau=2)                  # centered, tau = 2

Julia

using StatsBase
include("RAD.jl")

t = 1:2000
x = @. sin(0.3*t) + 0.3*cos(1.7*t) + 0.1*sin(0.011*t^2)

RAD(x, 1, false)  # uncentered, tau = 1
RAD(x)            # centered, tau = 1 (the defaults)
RAD(x, 2)         # centered, tau = 2

RAD needs a series with enough distinct values for both halves of the median split to have a nonzero spread. When either half of the median split has fewer than two values or no spread, RAD returns NaN with a warning. This happens for constant or very short series, and for integer-valued or heavily quantized series (for example, spike counts) where many values are tied.

Other implementations

RAD is also available in other packages in the group's ecosystem:

  • pyhctsa (Python): pyhctsa.operations.criticality.rad, computed in the hctsa feature set at τ = 1, τ = 2 and an automatically chosen τ. pyhctsa is where the hctsa feature library is actively developed.
  • hctsa (MATLAB): the operation CR_RAD, used for the features CR_RAD_1, CR_RAD_2 and CR_RAD_tau. hctsa is now frozen, with new work going into pyhctsa.
  • TimeseriesFeatures.jl (Julia): the RAD function and the CR_RAD (centered) and CR_RAD_raw features.

Citation

If you use RAD, please cite the paper:

@article{Harris2024Tracking,
  title   = {Tracking the Distance to Criticality in Systems with Unknown Noise},
  author  = {Harris, Brendan and Gollo, Leonardo L. and Fulcher, Ben D.},
  journal = {Physical Review X},
  volume  = {14},
  pages   = {031021},
  year    = {2024},
  doi     = {10.1103/PhysRevX.14.031021}
}

The code is archived on Zenodo: 10.5281/zenodo.12660859.

License

The code is released under the MIT License.

About

Code for RAD in your favourite language

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages