-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRAD.jl
36 lines (30 loc) · 1.04 KB
/
RAD.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using StatsBase
"""
RAD(x, τ=1, doAbs=true)
Compute the rescaled auto-density, a metric for inferring the
distance to criticality that is insensitive to uncertainty in the noise strength.
Calibrated to experiments on the radial compenent of the Hopf bifurcation with
variable and unknown measurement noise.
Inputs:
x: The input time series (vector).
doAbs: Whether to centre the time series at 0 then take absolute values (logical flag)
τ: The embedding and differencing delay in units of the timestep (integer)
Outputs:
f: The RAD feature value
"""
function RAD(z, τ::Integer = 1, doAbs::Bool = true)
if doAbs
z = z .- median(z)
z = abs.(z)
end
y = @view z[(τ + 1):end]
x = @view z[1:(end - τ)]
# Median split
subMedians = x .< median(x)
superMedianSD = std(x[.!subMedians])
subMedianSD = std(x[subMedians])
# Properties of the auto-density
sigma_dx = std(y - x)
densityDifference = 1 / superMedianSD - 1 / subMedianSD
f = sigma_dx * densityDifference
end