bayesjax
Bayesjax is the JAX/BlackJAX NUTS backend for Bayeswire models. It binds concrete data, compiles transformed log densities, runs NUTS, reports essential diagnostics, and provides supported prior-predictive simulation.
The declaration language, IR, distributions and constraints metadata, specs, and conformance corpus belong to Bayeswire. Workflow orchestration and durable run directories belong to Bayescycle.
Sample a model
import jax.numpy as jnp
from bayeswire import Data, Observed, Param, model
from bayeswire.constraints import Positive
from bayeswire.distributions import Normal, Truncated
from bayesjax import bind_model
from bayesjax.diagnostics import ess, rhat
from bayesjax.inference import sample
@model
class LinearRegression:
alpha = Param(Normal(0.0, 1.0))
beta = Param(Normal(0.0, 1.0))
sigma = Param(
Truncated(Normal(0.0, 1.0), lower=0.0),
constraint=Positive(),
)
x = Data.vector()
y = Observed(Normal(alpha + beta * x, sigma))
x = jnp.linspace(-3.0, 3.0, 50)
y = 2.0 + 0.5 * x
bound = bind_model(LinearRegression, {"x": x, "y": y})
result = sample(
bound,
seed=42,
num_chains=4,
num_warmup=200,
num_samples=500,
)
print(rhat(result.samples))
print(ess(result.samples))
result.samples maps parameter names to constrained arrays shaped
(num_chains, num_samples, *param_shape). Warmup and retained-draw NUTS
statistics are separate in result.diagnostics; divergences are available at
result.diagnostics.sampling.is_divergent.
Backend semantics
- NUTS is the only inference algorithm; BlackJAX is internal.
bind_model(...)is the explicit transition from Bayeswire metadata to a validatedBoundModel.- Constraints define transforms and Jacobians. A prior needing truncation
normalization must use explicit
Truncated(...)with matching bounds. - Discrete distributions are valid observed likelihoods and prior-predictive outcomes, but discrete latent parameters are unsupported by NUTS.
OrderedLogisticobserved labels are zero-based.- Partially observed continuous vectors use an explicit observed/missing index partition; discrete missing latents are unsupported.
- Additional density factors are evaluated by the log-density compiler but are rejected by prior-predictive simulation when no ancestral sampling semantics exist.
Complete backend invariants are in docs/invariants.md.
InferenceData-compatible schema
Bayesjax does not depend on ArviZ, xarray, NetCDF, or Zarr. Downstream exporters can consume its typed adapter:
from bayesjax.interop.inferencedata import inferencedata_groups
schema = inferencedata_groups(bound, result)
The schema contains posterior draws, post-warmup sample statistics, observed and constant data, and declared dimension metadata without constructing an ArviZ object.
Conformance and references
Bayesjax consumes every installed Bayeswire corpus fixture and is the float64
oracle used to generate its expected log-density and gradient values. Optional
Stan fixtures and validation commands are documented in
reference/stan/README.md.
Development
uv run ruff format --check .
uv run ruff check .
uv run ty check
uv run pytest
See AGENTS.md for numerical and architecture rules.
Metadata
Release files for bayesjax 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bayesjax-0.7.0.tar.gz | 35.4 kB | Without provenance | Details for bayesjax-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bayesjax-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for bayesjax-0.7.0-py3-none-any.whl |
Total release size: 79.5 kB
Release files / bayesjax-0.7.0.tar.gz
| Download URL | bayesjax-0.7.0.tar.gz |
|---|---|
| Size | 35.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d24934ce01319b4f45ec1c53d064c972793c8a28688d23c7588fb86ae3cf531f
|
|
BLAKE2b-256 checksum How to use checksums |
990060d9cea5927ac52d7ff78990af0c049fb65c409c6618515c81cfad3fdd66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / bayesjax-0.7.0-py3-none-any.whl
| Download URL | bayesjax-0.7.0-py3-none-any.whl |
|---|---|
| Size | 44.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2bbd0e0d44c3f21b9757c324b19468683ee0c9f1444aa98c32853c5674b4bd9e
|
|
BLAKE2b-256 checksum How to use checksums |
cedebbf291006d59e6cb58a2dc4b2ea65a26e9c47e437ca9133ad7c344da5db0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for bayesjax 0.7.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.