Shapes and Sampling

This section describes the microstate shapes used in Recurrence Microstates Analysis (RMA) and the sampling strategies employed to construct histograms and distributions.

Variations of microstates shapes

A microstate shape defines the local recurrence pattern extracted from a recurrence plot. In RecurrenceMicrostatesAnalysis.jl, microstate shapes are represented by subtypes of MicrostateShape.

A MicrostateShape specifies:

  • which relative positions are sampled to evaluate recurrences, and
  • how the resulting binary recurrence pattern is mapped to a decimal representation.

The internal conversion from a microstate pattern to its decimal index is performed by the compute_motif function.

RecurrenceMicrostatesAnalysis.MicrostateShapeType
MicrostateShape

Abstract supertype defining the basic structure and layout of a microstate (or motif).

A MicrostateShape specifies which relative positions are retrieved from the data to evaluate recurrences, and how these binary recurrence values are interpreted and mapped to a decimal representation for counting.

All subtypes of MicrostateShape must include a field expr, which defines the RecurrenceExpression used to compute recurrences.

Implementations

source

Implemented microstates shapes

RecurrenceMicrostatesAnalysis.RectType
Rect <: MicrostateShape

Define a rectangular microstate shape.

Rect can represent either a two-dimensional microstate (identified as Rect2, used for Recurrence Plots and Cross-Recurrence Plots) or an N-dimensional microstate (identified as RectN, used for spatial data).

Rect2 (time-series data)

A 2D rectangular microstate can be initialized using either of the following constructors:

Rect(expr::E; rows = 2, cols = 2, B = 2)
Rect(rows::Int, cols::Int; expr = Standard(0.27), B = 2)

Here, rows and columns define the rectangle dimensions, expr is the RecurrenceExpression used to evaluate recurrences, and B is the base used to encode microstate elements (typically 2, representing recurrence or non-recurrence).

Rectangular microstates can be specialized to define common patterns such as lines, columns, and squares:

line = Rect(expr; rows = n, cols = 1)
column = Rect(expr; rows = 1, cols = n)
square = Rect(expr; rows = n, cols = n)

Since square microstates are frequently used, a convenience constructor is also provided:

Rect(expr::E, N; B = 2)

where N defines the size of the square microstate. For example:

square = Rect(expr, n)

RectN (spatial data)

For N-dimensional structures, typically used with spatial data, the RectN variant can be initialized as:

Rect(expr::E, structure::NTuple{D, Int}; B = 2)

Here, structure defines the size of the microstate along each dimension. For example:

nrect = Rect(expr, (2, 1, 2, 1))

This form is suitable for N-dimensional spatial data, such as images or volumetric datasets.

source
RecurrenceMicrostatesAnalysis.TriangleType
Triangle{N, B, E<:RecurrenceExpression} <: MicrostateShape

Triangle{N, B, E<:RecurrenceExpression} <: MicrostateShape

Define a triangular microstate shape, originally introduced by Hirata in 2021 (Hirata, 2021).

Constructor

Triangle(expr::E, N::Int; B::Int = 2)

where expr is the RecurrenceExpression used to evaluate recurrences and N defines the size of the triangular microstate.

Example

n = 3
triangle = Triangle(expr, n)

The corresponding microstate structure is given by:

\[\begin{pmatrix} R_{i,j} & R_{i,j + 1} & R_{i,j + 2} \\ & R_{i + 1,j + 1} & R_{i + 1,j + 2} \\ & & R_{i + 2,j + 2} \\ \end{pmatrix}\]

Compat

Triangular microstate shape is not compatible with spatial data.

source
RecurrenceMicrostatesAnalysis.DiagonalType
Diagonal <: MicrostateShape

Define a diagonal microstate shape, which captures recurrences along diagonals of a Recurrence Plot (RP).

Constructor

Diagonal(expr::E, N::Int; B::Int = 2)

where expr is the RecurrenceExpression used to evaluate recurrences and N defines the length of the diagonal microstate.

Example

diagonal = Diagonal(expr, 3)
Info

Diagonal microstates are compatible with spatial data. However, they do not capture hyper-diagonals in Spatial Recurrence Plots (SRP). Only diagonals defined by sequential recurrences are supported, such as:

\[R_{i_1,i_2,j_1,j_2}, R_{i_1 + 1,i_2 + 1,j_1 + 1,j_2 + 1}, R_{i_1 + 2,i_2 + 2,j_1 + 2,j_2 + 2}, \ldots, R_{i_1 + n - 1,i_2 + n - 1,j_1 + n - 1,j_2 + n - 1}\]

source

Sampling strategies

The sampling strategy determines which microstates are selected during histogram or distribution construction.

Sampling behavior is defined by subtypes of SamplingMode, while the set of valid sampling positions is determined by a SamplingSpace.

Implemented sampling modes

RecurrenceMicrostatesAnalysis.SRandomType
SRandom{F<:Real} <: SamplingMode

Sampling mode that randomly selects microstate positions $(i, j)$ within the SamplingSpace.

Constructors

SRandom(num_samples::Int)
SRandom(ratio::Union{Float32, Float64})

The sampling mode can be initialized either by specifying the exact number of microstates to sample or by providing a ratio of the total number of possible microstates.

Examples

s = SRandom(1000)   # Specify the exact number of sampled microstates
s = SRandom(0.05)   # Specify a ratio of the total possible microstates
source