Skip to content

Commit 2961a32

Browse files
authored
doc updates for histogram stuff (#44)
* doc updates for histogram stuff * add VENTR to @windowed * don't test nightly
1 parent d8f947e commit 2961a32

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ os:
44
- linux
55
julia:
66
- 1.0
7-
- nightly
7+
# - nightly
88
branches:
99
- only:
1010
- master

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
environment:
22
matrix:
33
- julia_version: 1
4-
- julia_version: nightly
4+
# - julia_version: nightly
55

66
platform:
77
- x86 # 32-bit

src/histograms.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ end
1515
# from the indices of rows and columns/diagonals of the matrix
1616
# `theiler` is used for histograms of vertical structures
1717
# `distances` is used to simplify calculations of the distances are not wanted
18-
function _linehistograms(rows::T, cols::T, lmin::Integer=1, theiler::Integer=0,
18+
function _linehistograms(rows::T, cols::T, lmin::Integer=1, theiler::Integer=0,
1919
distances::Bool=true) where {T<:AbstractVector{Int}}
20-
20+
2121
# check bounds
2222
n = length(rows)
2323
if length(cols) != n
@@ -61,7 +61,7 @@ function _linehistograms(rows::T, cols::T, lmin::Integer=1, theiler::Integer=0,
6161
halfline = div(current_vert, 2)
6262
if dist != 0
6363
nbins_d = extendhistogram!(bins_d, nbins_d, dist+halfline)
64-
end
64+
end
6565
# update the distance
6666
dist = r-rprev+halfline-1
6767
else
@@ -161,10 +161,11 @@ rt_histogram(x; kwargs...) = verticalhistograms(x; kwargs...)[2]
161161
vertical=true,
162162
recurrencetimes=true,
163163
kwargs...)
164-
165-
Histograms of the recurrence structures contained in the recurrence matrix `x`.
166164
167-
## Description:
165+
Return a dictionary with the
166+
histograms of the recurrence structures contained in the recurrence matrix `x`.
167+
168+
## Description
168169
169170
Returns a dictionary with the keys `"diagonal"`, `"vertical"` or
170171
`"recurrencetimes"`, depending on what keyword arguments are given as `true`.
@@ -181,15 +182,17 @@ All the points of the matrix are counted by default. Extra keyword arguments can
181182
be passed to rule out the lines shorter than a minimum length or around the main
182183
diagonal. See the arguments of the function [`rqa`](@ref) for further details.
183184
184-
## References:
185+
"Empty" histograms are represented always as `[0]`.
186+
187+
## References
185188
186189
N. Marwan & C.L. Webber, "Mathematical and computational foundations of
187190
recurrence quantifications", in: Webber, C.L. & N. Marwan (eds.), *Recurrence
188191
Quantification Analysis. Theory and Best Practices*, Springer, pp. 3-43 (2015).
189192
"""
190193
function recurrencestructures(x::ARM;
191194
diagonal=true, vertical=true, recurrencetimes=true, lmin=1, theiler=0, kwargs...)
192-
195+
193196
# Parse arguments for diagonal and vertical structures
194197
histograms = Dict{String,Vector{Int}}()
195198
if diagonal
@@ -208,4 +211,3 @@ function recurrencestructures(x::ARM;
208211
end
209212
return histograms
210213
end
211-

src/rqa.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ end
8080
@deprecate rqaentropy dl_entropy
8181

8282
"""
83-
determinism(x::AbstractRecurrenceMatrix; lmin=2, theiler=0)
83+
determinism(x; lmin=2, theiler=0)
8484
8585
Calculate the determinism of the recurrence matrix `x`, ruling out
8686
the points within the Theiler window of size `theiler` and diagonals shorter
@@ -151,7 +151,7 @@ end
151151
laminarity(x; lmin=2, theiler=0)
152152
153153
Calculate the laminarity of the recurrence matrix `x`, ruling out the
154-
points within the Theiler window of size `theiler` and diagonals shorter
154+
points within the Theiler window of size `theiler` and lines shorter
155155
than `lmin`.
156156
"""
157157
function laminarity(x::ARM; kwargs...)
@@ -165,7 +165,7 @@ _laminarity(vert_hist::Vector{<:Integer}, npoints) = _determinism(vert_hist, npo
165165
trappingtime(x; lmin=2, theiler=0)
166166
167167
Calculate the trapping time of the recurrence matrix `x`, ruling out the
168-
points within the Theiler window of size `theiler` and diagonals shorter
168+
points within the Theiler window of size `theiler` and lines shorter
169169
than `lmin`.
170170
171171
The trapping time is the average of the vertical line structures and thus equal
@@ -182,7 +182,7 @@ trappingtime(x::ARM; kwargs...) = vl_average(x; kwargs...)
182182
meanrecurrencetime(x; lmin=2, theiler=0)
183183
184184
Calculate the mean recurrence time of the recurrence matrix `x`, ruling out the
185-
points within the Theiler window of size `theiler` and diagonals shorter
185+
points within the Theiler window of size `theiler` and lines shorter
186186
than `lmin`.
187187
188188
Equivalent to [`rt_average`](@ref).
@@ -194,7 +194,7 @@ meanrecurrencetime(x::ARM; kwargs...) = rt_average(x; kwargs...)
194194
nmprt(x; lmin=2, theiler=0)
195195
196196
Calculate the number of the most probable recurrence time (NMPRT), ruling out the
197-
points within the Theiler window of size `theiler` and diagonals shorter
197+
points within the Theiler window of size `theiler` and lines shorter
198198
than `lmin`.
199199
"""
200200
nmprt(x::ARM; kwargs) = maximum(verticalhistograms(x; kwargs...)[2])
@@ -229,10 +229,17 @@ The returned value is a dictionary with the following keys:
229229
* "LAM": laminarity (see [`laminarity`](@ref))
230230
* "TT": trapping time (see [`trappingtime`](@ref))
231231
* "Vmax": maximum length of vertical structures (see [`vl_max`](@ref))
232+
* "VENTR": entropy of vertical structures (see [`vl_entropy`](@ref))
232233
* "MRT": mean recurrence time (see [`meanrecurrencetime`](@ref))
233234
* "RTE" recurrence time entropy (see [`rt_entropy`](@ref))
234235
* "NMPRT": number of the most probable recurrence time (see [`nmprt`](@ref))
235236
237+
Notice that in the case of empty histograms (e.g. no existing vertical lines
238+
less than the keyword `lminvert`) the average and maximum values
239+
("L", "Lmax", "TT", "Vmax", "MRT")
240+
are returned as `0.0` but their respective entropies ("ENTR", "VENTR", "RTE")
241+
are returned as `NaN`.
242+
236243
The keyword argument `onlydiagonal` (`false` by default) can be set to `true`
237244
in order to restrict the analysis to the recurrence rate and the parameters related
238245
to diagonal structures ("RR", "DET", "L", "Lmax", "DIV" and "ENTR").
@@ -268,6 +275,7 @@ function rqa(x; onlydiagonal=false, kwargs...)
268275
"LAM" => _laminarity(vhist, rr_v*length(x)),
269276
"TT" => _vl_average(vhist),
270277
"Vmax" => _vl_max(vhist),
278+
"VENTR" => _vl_entropy(vhist),
271279
"MRT" => _rt_average(rthist),
272280
"RTE" => _rt_entropy(rthist),
273281
"NMPRT" => maximum(rthist)

src/windowed.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ const rqa_types = Dict(
2626

2727
"""
2828
ij_block_rmat(x, y, bsize, dindex, vargs...; kwargs...)
29-
29+
3030
Return the indices of the rows and columns of the nonzero values of a
3131
block-diagonal cross-recurrence matrix.
3232
33-
If `m` is the cross-recurrence matrix of `x` and `y` (created with the
33+
If `m` is the cross-recurrence matrix of `x` and `y` (created with the
3434
positional and keyword arguments `vargs` and `kwargs`), the indices returned by
3535
this function are limited to the "block-diagonal" indicated by
3636
`dindex ∈ {-1,0,1}`, as in the following graphical representation
@@ -163,6 +163,7 @@ macro windowed(ex, options...)
163163
"LAM" => zeros(Float64,ni),
164164
"TT" => zeros(Float64,ni),
165165
"Vmax" => zeros(Int,ni),
166+
"VENTR" => zeros(Float64,ni),
166167
"MRT" => zeros(Float64,ni),
167168
"RTE" => zeros(Float64,ni),
168169
"NMPRT" => zeros(Int,ni)

0 commit comments

Comments
 (0)