Skip to main content

correlation

Tools for computing time correlation functions of real-valued trajectories, with FFT, PyTorch, conditional, and incremental HDF5 workflows.

Installation

Install the package and its Python dependencies with pip:

pip install .

The Rust extension always builds with both CPU and CUDA support. Build a wheel for your target platform and Python version with Maturin:

maturin build --release
pip install target/wheels/correlation-*.whl

The Rust extension loads the NVIDIA driver when it tries to use CUDA. CPU-only machines can use the same wheel. The Rust CUDA path uses the embedded PTX and requires a compatible NVIDIA driver. The separate PyTorch CUDA path requires a CUDA-enabled PyTorch installation.

Features and usage

Correlation functions

correlation(a, b=None, trunc=None) computes an autocorrelation when b is omitted, or a cross-correlation when b is supplied. It supports one- and two-dimensional NumPy arrays and uses mkl_fft.

import numpy as np
from correlation import correlation

x = np.random.randn(10000)
acf = correlation(x)                 # autocorrelation
cross = correlation(x, np.roll(x, 1), trunc=1000)

correlation_torch provides the same operation through PyTorch and accepts a device such as "cpu" or "cuda". Install PyTorch separately with pip install torch to use it.

from correlation import correlation_torch

acf_gpu = correlation_torch(x, device="cuda")

Conditional correlation

ConditionalCorrelation is a Rust-backed accumulator. Choose a trajectory range and number of bins, then add trajectory arrays and retrieve the result:

from correlation import ConditionalCorrelation

cc = ConditionalCorrelation(100, 8, (-2.0, 2.0), cond_start=True)
cc.add_data(x, x, condition)
result = cc.get_result()

The default device is "cpu". device="auto" selects CUDA when the driver can load the kernel and cond_start=True, cond_end=False. Otherwise it selects CPU. Explicit device="cuda" (or "gpu") raises an error if the driver, kernel, or conditioning mode is unavailable. The device property reports the selected backend.

add_data accepts float32 and float64 NumPy arrays on both backends. The CPU computes in double precision. The CUDA kernel converts inputs to single precision. Use device="cpu" to keep double precision.

ConditionalCorrelationFFT accumulates conditional correlations using FFTs. Construct it with from_range(nbins, traj_range, trunc) or from_dx(dx, nbins, start, trunc), add trajectories with add_data(...), then call get_result(). Without PyTorch, add_data_cuda(...) issues a warning and uses add_data(...) on the CPU.

Incremental HDF5 correlation

IterativeCorrelation and its VVCorr (velocity autocorrelation function) and XdUCorr (position gradient-of-pmf correlation function) variants support correlation calculations over chunked HDF5 datasets, limiting memory use for large inputs. See their class docstrings for the dataset and observable arguments.

Metadata

Release files for correlation-fft 0.1.4

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

Source distribution (sdist)

Source distribution for correlation-fft 0.1.4
File Size Uploaded Provenance Actions
correlation_fft-0.1.4.tar.gz 57.5 kB Without provenance Details for correlation_fft-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for correlation-fft 0.1.4
File Interpreter ABI Platform Actions
correlation_fft-0.1.4-cp310-abi3-manylinux_2_34_x86_64.whl CPython 3.10 abi3 Linux glibc 2.34+ x86-64 Details for correlation_fft-0.1.4-cp310-abi3-manylinux_2_34_x86_64.whl

Total release size: 886.0 kB

Release files / correlation_fft-0.1.4.tar.gz

Download URL correlation_fft-0.1.4.tar.gz
Size 57.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e5a9b6d33e74a4042e2b0e1276659ee4459137fc20614cc2f742124364fdc785
BLAKE2b-256 checksum
How to use checksums
4a8a3c413f61ae02fcc7ebf04e8300261053e5cdfe2d41f4cbbf2013a7cc8d54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Release files / correlation_fft-0.1.4-cp310-abi3-manylinux_2_34_x86_64.whl

Download URL correlation_fft-0.1.4-cp310-abi3-manylinux_2_34_x86_64.whl
Size 828.6 kB
Tags CPython 3.10 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
ff8a9a4c4280be8e0fe2bf290ddf4b17e9a5187b74422126bf518f69cf35cfe9
BLAKE2b-256 checksum
How to use checksums
aa30fe8d216112a2c185a1c5e59b26f98fd465779627d71586b97e6dba2455e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.18

Security for correlation-fft 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files No provenance

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