Skip to main content

Python library for DFA, Hurst exponent, and fluctuation analysis of time series.

Project description

FluctuationAnalysisTools

GitHub Release GitHub Actions Workflow Status GitHub License PyPI - Downloads

A Python library for creating and processing long-term dependent datasets, with a focus on statistical analysis tools for fluctuation analysis, time series generation, and signal processing.

Table of Contents

Features

  • Synthetic Data Generation: Create datasets with controlled statistical properties (Hurst exponent, long-term dependencies) including:
    • Kasdin method for fractional Brownian noise (Kasdin, N. J. (1995). Discrete simulation of colored noise and stochastic processes and 1/f/sup /spl alpha// power law noise generation.).
    • FFT-based N-dimensional fractional Brownian motion (fBm) generator (Timmer, J., & Koenig, M. (1995). On generating power law noise).
  • Fluctuation Analysis: Perform various fluctuation analysis methods including:
    • Detrended Fluctuation Analysis (DFA)
    • Detrended Partial Cross-Correlation Analysis (DPCCA)
    • Standard Fluctuation Analysis (FA)
    • SVD-based DFA
    • Multidimensional DFA
    • Quantitative Signal Analysis (QSS)
  • Research Tools: Support scientific research in complex systems exhibiting long-range correlations
  • Performance Optimized: Multi-threaded implementations with C++ extensions for large datasets

Requirements

  • Python 3.8+
  • NumPy
  • SciPy
  • Matplotlib (for visualization)
  • C++ compiler (Mac and Windows packages contains precompiled binaries)

Installation

You can install FluctuationAnalysisTools from PyPI:

pip install FluctuationAnalysisTools

Or clone the repository and install locally:

git clone https://github.com/Digiratory/FluctuationAnalysisTools.git
cd StatTools
pip install .

Quick Start

You can find examples and published usages in the folder Research

If you used the project in your paper, you are welcome to ask us to add reference via a Pull Request or an Issue.

Generating Synthetic Data

from StatTools.generators import generate_fbn
import numpy as np

# Create a dataset with Hurst exponent H = 0.8 using the unified interface
hurst = 0.8
length = 1440

# Generate fractional Brownian noise using the default Kasdin method
fbn_series = generate_fbn(hurst=hurst, length=length)
print(f"Generated fBn series with shape: {fbn_series.shape}")

Analyzing Time Series

Detrended Fluctuation Analysis

from StatTools.generators import generate_fbn
from StatTools.analysis.dfa import dfa
from StatTools.analysis.utils import analyse_zero_cross_ff
import numpy as np

h = 0.7  # choose Hurst parameter
length = 6000  # vector's length

# Generate synthetic data using modern unified interface
trajectory = generate_fbn(hurst=h, length=length, method="kasdin").flatten()

# Analyze using functional-style DFA interface
s_vals, f2_vals = dfa(trajectory, degree=2)

# Calculate Hurst exponent from fluctuation function
f_vals = np.sqrt(f2_vals).reshape(1, -1)  # Convert F^2(s) to F(s) and reshape for analysis
s_vals_2d = s_vals.reshape(1, -1)  # Reshape scales to 2D array
hurst_result, _ = analyse_zero_cross_ff(f_vals, s_vals_2d)
hurst_exponent = hurst_result.slopes[0].value

print(f"Estimated H: {hurst_exponent:.3f} (Expected: {h:.3f})")

Support

For questions and discussions:

Research and Examples

Find comprehensive examples and published research in the research/ folder:

If you've used StatTools in your research, consider contributing your examples via a Pull Request or Issue.

Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • Setting up a development environment
  • Code style and standards
  • Testing guidelines
  • Submitting pull requests

License

This project is licensed under the terms specified in LICENSE.txt.

Citation

If you use FluctuationAnalysisTools in your research, please cite:

@article{bogachev2023understanding,
  title={Understanding the complex interplay of persistent and antipersistent regimes in animal movement trajectories as a prominent characteristic of their behavioral pattern profiles: Towards an automated and robust model based quantification of anxiety test data},
  author={Bogachev, Mikhail I and Lyanova, Asya I and Sinitca, Aleksandr M and Pyko, Svetlana A and Pyko, Nikita S and Kuzmenko, Alexander V and Romanov, Sergey A and Brikova, Olga I and Tsygankova, Margarita and Ivkin, Dmitry Y and others},
  journal={Biomedical signal processing and control},
  volume={81},
  pages={104409},
  year={2023},
  publisher={Elsevier}
}

and

@article{bogachev2023video,
  title={Video-based marker-free tracking and multi-scale analysis of mouse locomotor activity and behavioral aspects in an open field arena: a perspective approach to the quantification of complex gait disturbances associated with Alzheimer's disease},
  author={Bogachev, Mikhail and Sinitca, Aleksandr and Grigarevichius, Konstantin and Pyko, Nikita and Lyanova, Asya and Tsygankova, Margarita and Davletshin, Eldar and Petrov, Konstantin and Ageeva, Tatyana and Pyko, Svetlana and others},
  journal={Frontiers in Neuroinformatics},
  volume={17},
  pages={1101112},
  year={2023},
  publisher={Frontiers Media SA}
}

Changelog

See CHANGELOG.md for version history and updates.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluctuationanalysistools-1.10.0.tar.gz (7.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

fluctuationanalysistools-1.10.0-cp311-cp311-win_amd64.whl (162.7 kB view details)

Uploaded CPython 3.11Windows x86-64

fluctuationanalysistools-1.10.0-cp311-cp311-macosx_10_9_universal2.whl (256.6 kB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file fluctuationanalysistools-1.10.0.tar.gz.

File metadata

File hashes

Hashes for fluctuationanalysistools-1.10.0.tar.gz
Algorithm Hash digest
SHA256 a84b916ead03ad6d647a1ec76e37eedcb56e97bade0cc482a406da3008201bb7
MD5 7b6701e016e790975223e34aff102d4e
BLAKE2b-256 1f5752ebb41d927479ae2e7c79fa38bcd59801f621fac7515918253e7d0e2f72

See more details on using hashes here.

File details

Details for the file fluctuationanalysistools-1.10.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for fluctuationanalysistools-1.10.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3a3d371c3f8138821a3abc6a50e22f39a12c02a34e3d89b7311e577b753ebf5b
MD5 762602dd3e537af5592fca3edc901e1e
BLAKE2b-256 f910f306cf41ee23e04a39a489e632de63888f805c810af2be23f57c6bc9e08f

See more details on using hashes here.

File details

Details for the file fluctuationanalysistools-1.10.0-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for fluctuationanalysistools-1.10.0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 7c6675e95b7103e279699dc4a720926dcaf54894422f96c684e0283fc1fab5e6
MD5 f837ae6e4c3d0b7a756ad2fcfa492b01
BLAKE2b-256 e11c1bfaa0bda3dfe853fd134aed16b713528162c04310bf31ddeb80536aa605

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page