Skip to main content

numerax

tests Coverage Status docs DOI

Statistical and numerical computation functions for JAX, focusing on tools not available in the main JAX API.

📖 Documentation

Installation

pip install numerax

# With scientific ML dependencies like equinox
pip install numerax[sciml]

Features

Special Functions

Differentiable special functions missing from JAX:

import jax.numpy as jnp
import numerax

# Inverse functions for statistical distributions
x = numerax.special.gammap_inverse(p, a)  # Gamma quantiles
y = numerax.special.erfcinv(x)  # Inverse complementary error function

# Modified Bessel functions of the first kind, real order
i = numerax.special.ive(v, z)  # exp(-z) I_v(z); stable for large z
i = numerax.special.iv(v, z)  # I_v(z)

# Chi-squared distribution (includes JAX functions + custom ppf)
x = numerax.stats.chi2.ppf(q, df, loc=0, scale=1)

# Half-normal distribution (pdf, cdf, sf, ppf, isf and their logs)
x = numerax.stats.halfnorm.ppf(q, loc=0, scale=1)

# Split-normal distribution: separate scales below/above the mode
x = numerax.stats.splitnorm.ppf(q, loc=0, scale_left=1, scale_right=2)

Key features:

  • Inverse functions for statistical distributions missing from JAX
  • Full differentiability and JAX transformation support

Profile Likelihood

Efficient profile likelihood computation for statistical inference with nuisance parameters:

import jax.numpy as jnp
import numerax


# Example: Normal distribution with mean inference, variance profiling
def normal_llh(params, data):
    mu, log_sigma = params
    sigma = jnp.exp(log_sigma)
    return jnp.sum(
        -0.5 * jnp.log(2 * jnp.pi)
        - log_sigma
        - 0.5 * ((data - mu) / sigma) ** 2
    )


# Profile over log_sigma, infer mu
is_nuisance = [False, True]  # mu=inference, log_sigma=nuisance


def get_initial_log_sigma(data):
    return jnp.array([jnp.log(jnp.std(data))])


profile_llh = numerax.stats.make_profile_llh(
    normal_llh, is_nuisance, get_initial_log_sigma
)

# Evaluate profile likelihood
data = jnp.array([1.2, 0.8, 1.5, 0.9, 1.1])
llh_val, opt_nuisance, diff, n_iter = profile_llh(jnp.array([1.0]), data)

Key features:

  • Convergence diagnostics and configurable optimization parameters
  • Automatic parameter masking for inference vs. nuisance parameters

Utilities

Utilities for working with PyTree-based models, including parameter counting and model summaries.

from numerax.utils import count_params, tree_summary
import jax.numpy as jnp

# Count parameters in PyTree-based models
model = {"weights": jnp.ones((10, 5)), "bias": jnp.zeros(5)}
num_params = count_params(model)  # 55 parameters

# Pretty-print model structure (similar to Keras model.summary())
model = {
    "encoder": {
        "weights": jnp.ones((10, 20)),
        "bias": jnp.zeros(20),
    },
    "decoder": {
        "weights": jnp.ones((20, 5)),
        "bias": jnp.zeros(5),
    },
}
tree_summary(model)
# ======================================================================
# PyTree Summary
# ======================================================================
# Name                  Shape           Dtype             Params
# ----------------------------------------------------------------------
# root                                                       325
#   encoder                                                  220
#     - weights         [10,20]         float32              200
#     - bias            [20]            float32               20
#   decoder                                                  105
#     - weights         [20,5]          float32              100
#     - bias            [5]             float32                5
# ======================================================================
# Total params: 325
# ======================================================================

Key features:

  • Parameter counting for PyTree-based models including Equinox (requires numerax[sciml])
  • Model structure visualization with shapes, dtypes, and parameter counts
  • Decorators for preserving function metadata when using JAX's advanced features

Acknowledgements

This work is supported by the Department of Energy AI4HEP program and the National Institute of Education, Nanyang Technological University, Singapore.

Citation

If you use numerax in your research, please cite it using the citation information from Zenodo (click the DOI badge at the top of the README) to ensure you get the correct DOI for the version you used.

Metadata

Release files for numerax 1.5.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 numerax 1.5.0
File Size Uploaded Provenance Actions
numerax-1.5.0.tar.gz 307.7 kB With provenance Details for numerax-1.5.0.tar.gz

Built distribution (wheel)

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

Total release size: 341.7 kB

Release files / numerax-1.5.0.tar.gz

Download URL numerax-1.5.0.tar.gz
Size 307.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8126368f434e718bffc9c19332a0b56d0c75f4e4fc91741e050e236089b7d49f
BLAKE2b-256 checksum
How to use checksums
782b1f8bc8454085e4f620397f0cf47db9db4a48a0239d5ebed7e7abdafc320f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Release files / numerax-1.5.0-py3-none-any.whl

Download URL numerax-1.5.0-py3-none-any.whl
Size 34.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a227c5d9c8fad5e9e63eb77e4618b36a59fffbbd62137dbc916b3317bb8ed2e7
BLAKE2b-256 checksum
How to use checksums
286e46f3083b82c56ff583faa13279a77e1462253a45b26c343f6859fc5cbb0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 6, 2026.

Transparency log

Security for numerax 1.5.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for numerax-1.5.0.tar.gz

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 Nov 6, 2026.

Transparency log

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.

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