Utilitary functions
RecurrenceMicrostatesAnalysis.jl
has several utilitary functions to help when using the library. These functions allows to simplify the process to implement recurrence analysis to a project, facilitating the set of a threshold, or the preparation of continuous data to be analysed.
Some function presented in this section was still in development, so these function can change in future versions.
Preparing a continuous data
When working with continuous data, it is important to do a discretization, changing the time resolution to improve the available information. prepare
is an utilitary function to discretize the data, applying a vicinity parameter to change the data time resolution [10].
julia> function lorenz!(du, u, p, t) du[1] = 10.0 * (u[2] - u[1]) du[2] = u[1] * (28.0 - u[3]) - u[2] du[3] = u[1] * u[2] - (8 / 3) * u[3] end
lorenz! (generic function with 1 method)
julia> using DifferentialEquations, RecurrenceMicrostatesAnalysis
julia> u0 = [1.0; 0.0; 0.0];
julia> tspan = (0.0, 1000.0);
julia> prob = ODEProblem(lorenz!, u0, tspan);
julia> sol = solve(prob);
julia> data_prepared = prepare(sol, 0.2)
3×4133 Matrix{Float64}: 1.0 5.46738 12.3621 -5.86995 -8.91899 … 0.493252 5.04799 16.1972 0.0 11.6854 -4.1674 -8.32987 -9.88552 0.871561 9.8981 8.52887 0.0 2.49205 44.2997 26.4556 26.5527 10.5164 7.57713 43.8558
It is possible to see the difference between the data solution and the prepareted data when we make a RP.
The prepare
function can also apply a transient phase to the data, using the kword transient
, and define the data length, using the kword K
.
julia> data_prepared = prepare(sol, 0.2; transient = 6000, K = 1000)
3×1000 Matrix{Float64}: -0.89148 -4.24782 -15.1813 -1.40175 … 2.86423 16.7419 -0.439991 -1.90309 -7.4907 -12.1429 2.02437 5.35815 17.7081 -4.00474 18.2339 12.3067 38.8897 25.6219 9.20178 37.6122 25.3385
Finding threshold
The threshold is a free parameter that need to be defined by the user when working with RP, RQA, or RMA. Using the principle of maximizing the recurrence entropy, we build a function to estimate a good value for threshold [10]. The find_parameters
function returns a Float64
value to be used as threshold and the maximazed entropy. It is important to note that this function can be a little slower, since it needs to compute a recurrence motif distributions for each threshold in some interval.
julia> th, s = find_parameters(data_prepared, 3)
(17.07249006479173, 5.418566751884777)