-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatistical RQA.jl
More file actions
116 lines (95 loc) · 3.95 KB
/
Statistical RQA.jl
File metadata and controls
116 lines (95 loc) · 3.95 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using RecurrenceAnalysis, Statistics
function LAM_Probabilistic(mapp::Array{Float64, 1}; n=n, q=2, lmin=2, samples=Int(n/10), e=0.3)
#=
This function will calculate the determinism using a probabilistical approach. It will calculate various DET and average over them.
Input:
mapp: time series, data.
n: the size of the time series
q: the microstate that should be used
lmin: the minimum line length you want to consider
samples: the sampling rule you want to test (the suggested ]fast sampling rule is: floot(n/q) - note this is the default)
e: the threshold parameter you want
Outpub:
DET: the value of the determinism
=#
LAM = zeros(Float64, samples)
for s in 1:samples
s = Int(s)
a, b = rand(1:n-q+1), rand(1:n-q+1)
micro = CrossRecurrenceMatrix(mapp[a:a+q-1], mapp[b:b+q-1], e)
LAM[s] = laminarity(micro, theiler=0)
end
return mean(LAM)
end
function TT_Probabilistic(mapp::Array{Float64, 1}; n=n, q=2, lmin=2, samples=Int(n/10), e=0.3)
#=
This function will calculate the determinism using a probabilistical approach. It will calculate various DET and average over them.
Input:
mapp: time series, data.
n: the size of the time series
q: the microstate that should be used
lmin: the minimum line length you want to consider
samples: the sampling rule you want to test (the suggested ]fast sampling rule is: floot(n/q) - note this is the default)
e: the threshold parameter you want
Outpub:
DET: the value of the determinism
=#
TT = zeros(Float64, samples)
for s in 1:samples
s = Int(s)
a, b = rand(1:n-q+1), rand(1:n-q+1)
micro = CrossRecurrenceMatrix(mapp[a:a+q-1], mapp[b:b+q-1], e)
TT[s] = trappingtime(micro, theiler=0)
end
return mean(TT)
end
function DET_Probabilistic(mapp::Array{Float64, 1}; n=n, q=2, lmin=2, samples=0, e=0.3)
#=
This function will calculate the determinism using a probabilistical approach. It will calculate various DET and average over them.
Input:
mapp: time series, data.
n: the size of the time series
q: the microstate that should be used
lmin: the minimum line length you want to consider
samples: the sampling rule you want to test (the suggested ]fast sampling rule is: floot(n/q) - note this is the default)
e: the threshold parameter you want
Outpub:
DET: the value of the determinism
=#
if samples == 0
samples = Int(floor(n/q))
end
DET = zeros(Float64, Int(floor(samples)))
for s in 1:samples
s = Int(s)
a, b = rand(1:n-q+1), rand(1:n-q+1)
micro = CrossRecurrenceMatrix(mapp[a:a+q-1], mapp[b:b+q-1], e)
DET[s] = determinism(micro)
end
return mean(DET)
end
function L_Probabilistic(mapp::Array{Float64, 1}; n=n, q=2, lmin=2, samples=0, e=0.3)
#=
This function will calculate the determinism using a probabilistical approach. It will calculate various DET and average over them.
Input:
mapp: time series, data.
n: the size of the time series
q: the microstate that should be used
lmin: the minimum line length you want to consider
samples: the sampling rule you want to test (the suggested ]fast sampling rule is: floot(n/q) - note this is the default)
e: the threshold parameter you want
Outpub:
DET: the value of the determinism
=#
if samples == 0
samples = Int(floor(n/q))
end
L = zeros(Float64, Int(floor(samples)))
for s in 1:samples
s = Int(s)
a, b = rand(1:n-q+1), rand(1:n-q+1)
micro = CrossRecurrenceMatrix(mapp[a:a+q-1], mapp[b:b+q-1], e)
L[s] = average_l(micro)
end
return mean(L)
end