timeseries.recurrence_network¶
Provides classes for the analysis of dynamical systems and time series based on recurrence plots, including measures of recurrence quantification analysis (RQA) and recurrence network analysis.
- class pyunicorn.timeseries.recurrence_network.RecurrenceNetwork(time_series, metric='supremum', normalize=False, missing_values=False, silence_level=0, **kwds)[source]¶
Bases:
RecurrencePlot
,Network
Class RecurrenceNetwork for generating and quantitatively analyzing recurrence networks.
More information on the theory and applications of recurrence networks can be found in [Marwan2009], [Donner2010b].
Examples:
Create an instance of RecurrenceNetwork with a fixed recurrence threshold and without embedding:
RecurrenceNetwork(time_series, threshold=0.1)
Create an instance of RecurrenceNetwork at a fixed (global) recurrence rate and using time delay embedding:
RecurrenceNetwork(time_series, dim=3, tau=2, recurrence_rate=0.05).recurrence_rate()
- __init__(time_series, metric='supremum', normalize=False, missing_values=False, silence_level=0, **kwds)[source]¶
Initialize an instance of RecurrenceNetwork.
Creates an embedding of the given time series, calculates a recurrence plot from the embedding and then creates a Network object from the recurrence plot, interpreting the recurrence matrix as the adjacency matrix of a complex network.
Either recurrence threshold
threshold
/threshold_std
, recurrence raterecurrence_rate
or local recurrence ratelocal_recurrence_rate
have to be given as keyword arguments.Embedding is only supported for scalar time series. If embedding dimension
dim
and delaytau
are both given as keyword arguments, embedding is applied. Multidimensional time series are processed as is by default.- Parameters:
time_series (2D array (time, dimension)) – The time series to be analyzed, can be scalar or multi-dimensional.
metric (str) – The metric for measuring distances in phase space (“manhattan”, “euclidean”, “supremum”).
normalize (bool) – Decide whether to normalize the time series to zero mean and unit standard deviation.
missing_values (bool) – Toggle special treatment of missing values in
RecurrencePlot.time_series
.silence_level (number) – Inverse level of verbosity of the object.
threshold (number) – The recurrence threshold keyword for generating the recurrence network using a fixed threshold.
threshold_std (number) – The recurrence threshold keyword for generating the recurrence plot using a fixed threshold in units of the time series’ STD.
recurrence_rate (number) – The recurrence rate keyword for generating the recurrence network using a fixed recurrence rate.
local_recurrence_rate (number) – The local recurrence rate keyword for generating the recurrence plot using a fixed local recurrence rate (same number of recurrences for each state vector).
adaptive_neighborhood_size (number) – The adaptive neighborhood size parameter for generating recurrence plots based on the algorithm in [Xu2008].
dim (number) – The embedding dimension.
tau (number) – The embedding delay.
node_weights (1D array (time)) – The sequence of weights associated with each node for calculating n.s.i. network measures.
- local_clustering_dim_single_scale()[source]¶
Return local clustering dimension for a single scale.
The single scale local clustering dimension can be interpreted as a local measureof the dimensionality of the set of points underlying the recurrence network ([Donner2011b].). The scale is determined by the chosen recurrence threshold. Note that the maxima and minima of the single scale local clustering dimension when varying the scale give a more meaningful measure of dimensionality as is explained in [Donner2011b].
Attention: currently only works correctly for supremum norm.
- Return type:
1d numpy array [node] of float
- Returns:
the single scale transitivity dimension.
- set_adaptive_neighborhood_size(adaptive_neighborhood_size, order=None)[source]¶
Create a recurrence network using the adaptive neighborhood size algorithm used in [Xu2008].
The exact algorithm was deduced from private correspondence with the authors. It leads to an undirected network with mean degree \(<k> = 2 * m\), where m is the adaptive_neighborhood_size. The degree \(k_v\) of single nodes may vary, but \(k_v >= m\) holds!
- Parameters:
adaptive_neighborhood_size (number) – The number of adaptive nearest neighbors (recurrences) assigned to each state vector.
order (1D array (int32)) – The indices of state vectors in the order desired for processing by the algorithm.
- set_fixed_local_recurrence_rate(local_recurrence_rate)[source]¶
Create a recurrence network at a fixed local recurrence rate.
This leads to a directed recurrence network with identical out-degree \(int(N * local_recurrence_rate)\), but variable in-degree. The associated recurrence plot coincides with the original Eckmann definition.
- Parameters:
local_recurrence_rate (number) – The local recurrence rate.
- set_fixed_recurrence_rate(recurrence_rate)[source]¶
Create a recurrence network at a fixed link density (recurrence rate).
- Parameters:
recurrence_rate (number) – The link density / recurrence rate.
- set_fixed_threshold(threshold)[source]¶
Create a recurrence network at a fixed threshold.
- Parameters:
threshold (number) – The threshold.
- set_fixed_threshold_std(threshold_std)[source]¶
Set the recurrence network to a fixed threshold in units of the standard deviation of the time series.
- Parameters:
threshold_std (number) – The recurrence threshold in units of the standard deviation of the time series.
- transitivity_dim_single_scale()[source]¶
Return transitivity dimension for a single scale.
The single scale transitivity dimension can be interpreted as a global measure of the dimensionality of the set of points underlying the recurrence network ([Donner2011b].). The scale is determined by the chosen recurrence threshold. Note that the maxima and minima of the single scale transitivity dimension when varying the scale give a more meaningful measure of dimensionality as is explained in [Donner2011b].
Attention: currently only works correctly for supremum norm.
- Return type:
float
- Returns:
the single scale transitivity dimension.