Skip to main content

Rust-accelerated signal analysis primitives

Project description

pmtvs

Rust-accelerated signal analysis primitives.

numpy in, number out.

Python 3.12 License: PolyForm Strict

Installation

pip install pmtvs

Quick Start

from pmtvs import hurst_exponent
import numpy as np

signal = np.random.randn(1000)
h = hurst_exponent(signal)
print(f"Hurst exponent: {h:.3f}")
import numpy as np
from pmtvs import (
    sample_entropy, permutation_entropy,
    hurst_exponent, dfa,
    skewness, kurtosis,
    eigendecomposition, svd_decomposition,
    granger_causality, mutual_information,
)

signal = np.random.randn(5000)

# Entropy
print(sample_entropy(signal))       # ~2.19
print(permutation_entropy(signal))  # ~2.57

# Fractal
print(hurst_exponent(signal))       # ~0.50
print(dfa(signal))                  # ~0.50

# Statistics
print(skewness(signal))             # ~0.00
print(kurtosis(signal))             # ~3.00

What's Inside

232 functions in one flat import. Single wheel, no sub-packages.

Domain Functions Description
Entropy 6 Sample entropy, permutation entropy, LZ complexity
Fractal 7 Hurst exponent, DFA, rescaled range, variance growth
Statistics 34 Descriptive stats, calculus, derivatives, normalization
Correlation 15 Autocorrelation, cross-correlation, Spearman, Kendall, coherence
Distance 6 Euclidean, cosine, Manhattan, DTW, EMD
Embedding 5 Time delay embedding, FNN, Cao's method
Coupling 2 Rolling Spearman correlation
Dynamics 23 Lyapunov exponents, RQA, attractor reconstruction
Spectral 17 FFT (rustfft), PSD, Hilbert transform
Matrix 22 SVD, covariance, DMD, MI/Granger matrices
Topology 11 Persistent homology, Betti numbers
Network 10 Graph centrality, community detection
Information 15 Mutual information, KL divergence, Granger causality
Physics 1 Subspace angle
Tests stat tests Stationarity, hypothesis testing
Regression 5 Linear regression, signal arithmetic

Full mathematical reference with LaTeX equations: PRIMITIVES.md

Benchmarks

Measured on Mac Mini M4 (arm64), Python 3.12. Not theoretical — timed.

Function Speedup Why
dfa 267x Rust eliminates per-segment polyfit overhead
dtw_distance 94x O(n^2) — Rust loops crush Python loops
sample_entropy 31x O(n^2) template matching
permutation_entropy 28x Combinatorial pattern counting
hurst_exponent 20x Hybrid Rust/numpy by signal size
skewness 7x Single-pass Rust vs multi-pass numpy
kurtosis 8x Same
autocorrelation 4x
euclidean_distance 1.6x numpy BLAS — at parity
rms ~1x numpy BLAS — at parity
cosine_distance ~1x numpy BLAS — at parity

Overall: 41x mean, 326x max.

BLAS-backed ops (rms, cosine, euclidean) delegate to numpy when numpy's LAPACK/BLAS is faster. Algorithmic functions (loops, O(n^2), combinatorial) use Rust. No ego — just speed.

Run the benchmark yourself:

python benchmarks/rust_vs_python.py

Development

git clone https://github.com/pmtvs/pmtvs.git
cd pmtvs

# Install (requires Rust toolchain + maturin)
pip install maturin numpy scipy
cd packages/pmtvs && maturin develop --release

# Run tests
pytest packages/*/tests/ -v

Reporting Issues

The most useful bug report includes: a minimal code example, the value pmtvs returned, and the value you expected with a source (published paper, competing library, or analytical solution).

"sample_entropy returns 2.14 but Richman-Moorman Table 2 gives 2.09 for this test vector" is a perfect bug report.

Edge cases are especially welcome — constant signals, very short signals, NaN-heavy data, extreme outliers. If you can break it, we want to know.

Issues: issues@pmtvs.dev

Citation

@software{pmtvs2026,
  author    = {Rudder, Jason},
  title     = {pmtvs: Rust-Accelerated Signal Analysis Primitives},
  year      = {2026},
  publisher = {PyPI},
  url       = {https://pypi.org/project/pmtvs/}
}

Rudder Research © 2026

License

PolyForm Strict 1.0.0 with Additional Terms.

  • Students & individual researchers: Free. Cite us.
  • Funded research labs (grants > $100K): Academic Research License required.
  • Commercial use: Commercial License required.
  • Institutional deployment: Institutional License required.

Contact: licensing@pmtvs.dev

See LICENSE for full terms.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pmtvs-1.0.2-cp312-cp312-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

File details

Details for the file pmtvs-1.0.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pmtvs-1.0.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a7f7ef35be738932df98bbe2b14ea79dd77689e3d7c326d91189cc8a4ec1c52
MD5 8bfc83e9f8e34383557b6999350df0cd
BLAKE2b-256 1283298e8f82fd21f16aa4969adc3e6c7bbd701f65ead100c19e78567d120192

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