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.
- Synthetic Data Generation: Create datasets with controlled statistical properties (Hurst exponent, long-term dependencies)
- Fluctuation Analysis: Perform Detrended Fluctuation Analysis (DFA), Detrended Partial Cross-Correlation Analysis (DPCCA), and other methods
- Signal Processing: Apply filters and transformations to time series data
- Research Tools: Support scientific research in complex systems exhibiting long-range correlations
- Performance Optimized: Multi-threaded implementations with C++ extensions for large datasets
You can install StatTools from PyPI:
pip install FluctuationAnalysisTools
Or clone the repository and install locally:
git clone https://github.com/Digiratory/StatTools.git
cd StatTools
pip install .
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.
from StatTools.generators.base_filter import FilteredArray
import numpy as np
# Create a dataset with Hurst exponent H = 0.8
h = 0.8
total_vectors = 1000
vectors_length = 1440
threads = 8
# Generate correlated vectors
generator = FilteredArray(h, vectors_length)
correlated_vectors = generator.generate(n_vectors=total_vectors, threads=threads, progress_bar=True)
print(f"Generated {len(correlated_vectors)} vectors of length {len(correlated_vectors[0])}")
from StatTools.analysis.dfa import DFA
import numpy as np
# Generate sample data
np.random.seed(42)
data = np.random.randn(10000)
# Perform Detrended Fluctuation Analysis
dfa = DFA(data)
hurst_exponent = dfa.find_h()
print(f"Estimated Hurst exponent: {hurst_exponent:.3f}")
from StatTools.generators.lbfbm_generator import LBFBmGenerator
# Parameters
hurst_exponent = 0.8 # H ∈ (0, 2)
base = 1.2
sequence_length = 4000
# Create and use generator
generator = LBFBmGenerator(h=hurst_exponent, base=base, length=sequence_length)
signal = list(generator)
print(f"Generated signal of length {len(signal)}")
For more details, see lbfbm_generator.ipynb.
from StatTools.generators.kasdin_generator import KasdinGenerator
h = 0.8
target_len = 4000
generator = KasdinGenerator(h, length=target_len)
# Generate full sequence
signal = generator.get_full_sequence()
print(f"Generated signal: {signal[:10]}...") # First 10 values
# Or iterate through samples
signal_list = []
for sample in generator:
signal_list.append(sample)
Reference: Kasdin, N. J. (1995). Discrete simulation of colored noise and stochastic processes and 1/f^α power law noise generation. DOI:10.1109/5.381848.
from StatTools.generators.base_filter import Filter
from StatTools.analysis.dfa import DFA
import numpy as np
h = 0.7 # choose Hurst parameter
length = 6000 # vector's length
target_std = 1.0
target_mean = 0.0
generator = Filter(h, length, set_mean=target_mean, set_std=target_std)
trajectory = generator.generate(n_vectors=1)[0] # Get the first (and only) trajectory
actual_mean = np.mean(trajectory)
actual_std = np.std(trajectory, ddof=1)
actual_h = DFA(trajectory).find_h()
print(f"Estimated H: {actual_h:.3f} (Expected: {h:.3f})")
FilteredArray
: Base class for generating correlated datasetsLBFBmGenerator
: Linear Fractional Brownian Motion generatorKasdinGenerator
: Colored noise generator using Kasdin's methodFieldGenerator
: Spatial data generator
DFA
: Detrended Fluctuation AnalysisDPCCA
: Detrended Partial Cross-Correlation AnalysisFA
: Fluctuation AnalysisQSS
: Quantile Segmentation Statistics
KalmanFilter
: Kalman filtering implementation
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.
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
This project is licensed under the terms specified in LICENSE.txt.
If you use StatTools in your research, please cite:
@software{statttools,
title = {StatTools: A Python Library for Long-term Dependent Dataset Analysis},
author = {Kuzmenko, Alexandr and Sinitca, Aleksandr and Lyanova, Asya},
url = {https://github.com/Digiratory/StatTools},
version = {1.6.1}
}
See CHANGELOG.md for version history and updates.