Skip to content

Repository files navigation

Python Numpy Scipy License: GPL v3 version downloads

rft1d

One-Dimensional Random Field Theory in Python.

rft1d is a Python package for exploring and validating Random Field Theory (RFT) expectations regarding upcrossings in univariate and multivariate 1D continua. These expectations can be used to make statistical inferences regarding signals observed in experimentally measured 1D continua including scalar and vector time series.

Please cite:

Pataky TC (2016) RFT1D: Smooth One-Dimensional Random Field Upcrossing Probabilities in Python. Journal of Statistical Software 71(7): 1-22. https://doi.org/10.18637/jss.v071.i07

Documentation is available at: www.spm1d.org/rft1d


Installation

pip install rft1d

rft1d requires Python 3.9 or later, along with numpy, scipy and matplotlib.

rft1d has been tested on Python 3.9 through 3.13.


Running examples:

The scripts in ./examples call import rft1d so they need the package importable. Either install rft1d, or add the ./src directory to your PYTHONPATH.

The scripts in ./examples/paper reproduce the figures and code examples from the Journal of Statistical Software paper. Run ./examples/paper/all_results.py to run generate everything in one pass.


Development

The package uses a src layout, and the test suite adds ./src to sys.path itself (see tests/conftest.py), so no installation step is needed to work on the source:

git clone https://github.com/0todd0000/rft1d.git
cd rft1d
pip install pytest numpy scipy matplotlib

Running tests:

pytest                      # the whole suite
pytest -m "not slow"        # skip the 100,000-case validation (about 20 s)
pytest tests/test_p_RF.py   # a single file

The tests are:

  • test_p_RF.py and test_uc_RF.py check rft1d's probabilities and critical thresholds against reference values computed with SPM12b, which are stored in tests/data-spm12b. These establish that rft1d's probability calculations are correct.
  • test_geom.py checks cluster labeling, resel counts and cluster metrics against hand-calculated values.
  • test_random_rng.py checks that random fields are reproducible when a seed or generator is passed as rng.

Issues

Please report software bugs or other problems by searching existing issues or creating a new issue here.

About

One-Dimensional Random Field Theory in Python

Topics

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages