Skip to main content

jrmt — JAXed Random Matrix Theory

A JAX port of thrmt. Pure functional samplers for the classical real / complex / quantum random matrix ensembles, built on jax.numpy and jaxtyping.

Parity with thrmt

jrmt mirrors thrmt's public surface 1:1 — all 25 names from thrmt's __init__ (16 ensembles + 9 historical aliases) are available under jrmt. The single intentional API break is described below.

Migration of … thrmt (PyTorch) jrmt (JAX)
PRNG implicit, global torch.manual_seed(...) explicit, key is the first positional argument of every random function
Batching batch_shape=(B,) kwarg returning (B, …) jax.vmap(lambda k: fn(k, …))(jax.random.split(root_key, B)) — pure-functional
Device device=... kwarg dropped — use jax.device_put or JAX's implicit placement
dtype torch.{cdouble, cfloat, double, float} jnp.{complex128, complex64, float64, float32, bfloat16, float16}
Shape types runtime checks at the wrapper jaxtyping annotations: Float[Array, "n n"], Complex[Array, "n n"], PRNGKeyArray
Output of random_obs_csu's evdist callback evdist(*batch_shape, size, dtype, device) evdist(key, size, dtype) — the only documented public-API break (forced by JAX's PRNG plumbing)

For random_rho_pure, thrmt's bo_einsum keyword is gone — the JAX implementation always uses jnp.einsum for the outer product.

Install

pip install -e .

Requires Python ≥ 3.10, jax, and jaxtyping. Enable 64-bit precision before importing anything that uses complex128:

from jax import config
config.update("jax_enable_x64", True)

Use

import jax
import jax.numpy as jnp
import jrmt

key = jax.random.key(0)

# Single draw
h = jrmt.random_gue(key, size=8, sigma=1.0)
assert jnp.allclose(h, jnp.conjugate(h.T))

# Batched draw via vmap
keys = jax.random.split(key, 1000)
batch = jax.vmap(lambda k: jrmt.random_rho_hs(k, size=8))(keys)
assert batch.shape == (1000, 8, 8)

Tests

pytest                 # fast invariants + cross-library moment-matching
pytest -m slow         # asymptotic-law KS tests (~30 s)

Cross-library moment-matching (tests/test_cross_lib.py) needs both thrmt and torch installed in the environment; the other suites do not.

Metadata

Release files for jrmt 0.1.0

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

Source distribution (sdist)

Source distribution for jrmt 0.1.0
File Size Uploaded
jrmt-0.1.0.tar.gz 17.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jrmt 0.1.0
File Interpreter ABI Platform
jrmt-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.7 kB

Release files / jrmt-0.1.0.tar.gz

Download URL jrmt-0.1.0.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0ce5edcb9ec1cf689e7cc42db7da151b24d5669a0b7e6c90e2add4810ed90f7e
BLAKE2b-256 checksum
How to use checksums
d34f8195b808f7e3b2ec44c52349f6e513f4eabb4eb11b6e2deb231e2b8fadac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

Release files / jrmt-0.1.0-py3-none-any.whl

Download URL jrmt-0.1.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68b59f3fae20cda9e58956870d04f9cd932ab47c84f5e2f6fd8953298e5df91d
BLAKE2b-256 checksum
How to use checksums
c5d17656a2c06011056e778f622f615a1738696e583a1619386fe751689ea239
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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