Skip to main content

JAXed Random Matrix Theory

Project description

jrmtJAXed 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.

Project details


Download files

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

Source Distribution

jrmt-0.1.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

jrmt-0.1.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file jrmt-0.1.0.tar.gz.

File metadata

  • Download URL: jrmt-0.1.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jrmt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ce5edcb9ec1cf689e7cc42db7da151b24d5669a0b7e6c90e2add4810ed90f7e
MD5 7b9d81015718d2951e0c2304ad410278
BLAKE2b-256 d34f8195b808f7e3b2ec44c52349f6e513f4eabb4eb11b6e2deb231e2b8fadac

See more details on using hashes here.

Provenance

The following attestation bundles were made for jrmt-0.1.0.tar.gz:

Publisher: pypipublish.yml on emaballarin/jrmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file jrmt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jrmt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for jrmt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 68b59f3fae20cda9e58956870d04f9cd932ab47c84f5e2f6fd8953298e5df91d
MD5 3ae2f39309f47543942400d81e257530
BLAKE2b-256 c5d17656a2c06011056e778f622f615a1738696e583a1619386fe751689ea239

See more details on using hashes here.

Provenance

The following attestation bundles were made for jrmt-0.1.0-py3-none-any.whl:

Publisher: pypipublish.yml on emaballarin/jrmt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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