Skip to main content

No project description provided

Project description

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

Inverse functions for statistical distributions with differentiability support:

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

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

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.

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.

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

numerax-1.2.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

numerax-1.2.0-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

Details for the file numerax-1.2.0.tar.gz.

File metadata

  • Download URL: numerax-1.2.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for numerax-1.2.0.tar.gz
Algorithm Hash digest
SHA256 346a37cb0de581e28d4ac95b49327eb6d4c5df7595a7f0c9586025bedd27a0e5
MD5 d7b6e7f7c64cf68c290ec11f3c032888
BLAKE2b-256 7e76b676f0207acce673d863ee1fee6bb5e759c74860f8263bb869d0d9240d48

See more details on using hashes here.

Provenance

The following attestation bundles were made for numerax-1.2.0.tar.gz:

Publisher: publish.yml on juehang/numerax

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

File details

Details for the file numerax-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: numerax-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for numerax-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f045a946b9696a575059d69c96a73c5b94d00a2eedcbe14c61b59eebaf938630
MD5 f2ebbd45a1501ef7089af65c91297c10
BLAKE2b-256 23a58cfd0424a997649c717298830db77bac1ee32314f2ec5dfe0fb9caf46413

See more details on using hashes here.

Provenance

The following attestation bundles were made for numerax-1.2.0-py3-none-any.whl:

Publisher: publish.yml on juehang/numerax

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