Skip to main content

Event Analysis

Library for Event Synchronization and Event Coincidence Analysis

This Python library facilitates the calculation of Event Synchronization (ES) and Event Coincidence Analysis (ECA) for event series.

Understanding ECA and ES

To learn about ECA, read this 1 To learn about ES, read this 2

Installation

To install the library, execute the following command:

pip install event-analysis

Additional Requirement

To utilize the CUDA method, please install PyCuda separately.

Usage

Refer to the Example.ipnby Jupyter notebook for detailed usage instructions.

from EventAnalysis import EventAnalysis

# Initialize the Event Analysis object with your event dataframe
EA = EventAnalysis(event_dataframe)

# Perform Event Synchronization
Q = EA.ES()

# Calculate Event Coincidence Analysis
p_max, p_mean, t_max, t_mean = EA.ECA(time_delta)

# Calculate ECA with p-values
p_max, p_mean, t_max, t_mean, pval_p, pval_t = EA.ECA(time_delta, return_p_values=True)

# Important: Read the documentation for the EA constructor parameter time_normalization_factor before using the library.

Please read the notes for the EventAnalysis class before you use this library.

Documentation

EventAnalysis Class

Constructor:
EventAnalysis(self, event_df, device_Id=None, time_normalization_factor=3600)
Arguments
  • event_df: pandas.DataFrame
    • This DataFrame must have the following properties:
      • The index must be a pandas.DatetimeIndex.
      • The data type inside the DataFrame must be boolean.
      • Each column represents an event series.
  • device_Id: Optional int
    • Specify the ID of the NVIDIA GPU for computation. Defaults to 0 if not provided.
  • time_normalization_factor: Optional int
    • The library quantizes time to hours, ignoring minutes and seconds. This behavior can be overridden by changing this argument. Possible values include:
      • 1: Quantizes to seconds (allows for 69 years of data).
      • 60: Quantizes to minutes (allows for 4000 years of data).
      • 3600: (default) Quantizes to hours (allows for 250 centuries of data).
Returns:
  • An EventAnalysis object on which you can call the ES and ECA methods.

ES Method

ES(self, tauMax=np.Inf)
Arguments
  • tauMax: Optional, default is np.Inf
    • Currently not utilized; future functionality will be added. Please open an issue if needed.
Return
  • A DataFrame Q of shape N x N, where N is the number of event series. Use Q[event_series_1_name][event_series_2_name] to get the Event Synchronization between two series.

ECA Method

ECA(self, Delta_T_obj, tau=0, return_p_values=False, pValFillNA=True)
Arguments
  • Delta_T_obj: Required
    • Must be a datetime.timedelta object. It is quantized using the same time_normalization_factor as passed to the constructor.
  • tau: Optional, default is 0
    • A parameter of the ECA algorithm. Refer to the associated paper for details.
  • return_p_values: Optional, default is False
    • If set to True, it calculates the p-values for each combination of event series and returns them.
  • pValFillNA: Optional, default is True
    • Replaces NaN p-values with 1.

Return

  • EC_p_max
  • EC_p_mean
  • EC_t_max
  • EC_t_mean
  • pval_precursor (optional): Corresponds to the p-value of EC_p_max and EC_p_mean.
  • pval_trigger (optional): Corresponds to the p-value of EC_t_max and EC_t_mean.

Notes: The paper outlines the conditions for calculating p-values for ECA results:

  1. Na >> 1 and Nb >> 1

  2. ΔT << T/Na

Here, Na and Nb represent the number of events in series A and B, respectively. Δ𝑇 should be sufficiently less than the overall time.

ECA_vec

ECA_vec(self, Delta_T_objs, taus=0, return_p_values=False, pValFillNA=True)
Arguments
  • Delta_T_objs: Required
    • A list of datetime.timedelta objects.
  • taus: Optional, default is 0
    • Can be an integer, list, or numpy array of integers, matching the length of Delta_T_objs. If an integer is provided, all ECAs use that value.
  • return_p_values: Same as ECA.
  • pValFillNA: Same as ECA.
Returns
  • A generator that yields the ECA result for each corresponding pair of Delta_T_objs[i] and taus[i].

CUDA Support

All three methods can be executed on an NVIDIA GPU by appending _Cuda to their names: ES_Cuda, ECA_Cuda, ECA_vec_Cuda. Each requires an additional named parameter, block.

  • ES_Cuda(..., block=None)
    • Defaults to (16, 8, 1). Any tuple of the form (x, y, 1) where 𝑥 × 𝑦 is a multiple of the GPU's warp size is valid.
  • ECA_Cuda(..., block=None)
  • ECA_vec_Cuda(..., block=None)
    • Defaults to (32, 1, 1). Similar to ES_Cuda.

Notes: The p-values returned by the GPU may differ slightly from those calculated by the CPU due to floating-point precision. Setting epsilon to 10−2 should minimize these discrepancies.

References

  1. Event coincidence analysis for quantifying statistical interrelationships between event time series - Jonathan F. Donges, Carl-Friedrich Schleussner, Jonatan F. Siegmund, and Reik V. Donner

  2. Frederik Wolf, Jurek Bauer, Niklas Boers, and Reik V. Donner , "Event synchrony measures for functional climate network analysis: A case study on South American rainfall dynamics", Chaos 30, 033102 (2020) https://doi.org/10.1063/1.5134012

Release files for event-analysis 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for event-analysis 1.1.3
File Size Uploaded
event_analysis-1.1.3.tar.gz 13.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for event-analysis 1.1.3
File Interpreter ABI Platform
event_analysis-1.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 28.7 kB

Release files / event_analysis-1.1.3.tar.gz

Download URL event_analysis-1.1.3.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
4c2bdc21a136b5d485131fbb575deb81893a7152af9bdf744b9c39963bbcbad9
BLAKE2b-256 checksum
How to use checksums
22047ba2bca3800b5f3c04c997b903cf7f7e6e8b09ce884cf200dfe2e2d0f21e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.0

Release files / event_analysis-1.1.3-py3-none-any.whl

Download URL event_analysis-1.1.3-py3-none-any.whl
Size 15.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b852911c1e3da1be9a72c5fe5107f73c47644389a1112c33ec0c7831a8f4480d
BLAKE2b-256 checksum
How to use checksums
bc877084f1531e215bdacf021bb5e468754736e33db6ee34d9af9eb8432e08b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.0

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page