rxmc is an orchestration layer for Bayesian calibration of reaction models to
large data sets with flexible likelihood modeling.
It is built around two complementary workflows:
- External-sampler orchestration via
rxmc.config.CalibrationConfigfor drivers such asblack-box-bayes. - In-package end-to-end prototyping via
rxmc.walker.Walkerfor smaller problems where you want to run the full MCMC workflow locally.
The package composes:
- curated experimental data as
Observationobjects, - model predictions via
PhysicalModel, - statistical assumptions via
LikelihoodModel, - independent data-model pairings via
Constraint, - and full calibration problems via
Evidence.
git clone git@github.com:beykyle/rxmc.git
cd rxmc
pip install -ve .It is strongly recommended to use an isolated environment.
conda env create -f environment.yml
conda activate rxmc
pip install -ve . --no-depsmamba env create -f environment.yml
mamba activate rxmc
pip install -ve . --no-depspython -m venv .rxmc
source .rxmc/bin/activate
pip install -r requirements.txt
pip install -ve .uv env create
uv env use python
uv install -e .Install the example notebook runtime dependencies with:
pip install -ve '.[examples]'Install the full validation toolchain with:
pip install -ve '.[validation]'CalibrationConfig packages a calibration problem into a flat parameter space
for external drivers. It exposes the interface expected by
black-box-bayes-style tooling:
ndimstarting_location(nwalkers)log_posterior(theta)log_likelihood(theta)prior_transform(u)log_posterior_batch(thetas)(optional convenience interface)parameter_names
Typical flow:
- Build
Observationobjects from your measurements. - Define a
PhysicalModel. - Choose a
LikelihoodModel. - Combine them into
Constraintobjects and thenEvidence. - Wrap the problem in
ParameterConfigandCalibrationConfig. - Hand the resulting object to an external sampler.
This is the recommended path for larger production calibrations.
Walker is the smaller-scale, in-package path. It coordinates:
- one sampler for the physical-model parameters, and
- optional additional samplers for parametric likelihood sectors.
It alternates between these sectors in a Gibbs-style workflow and is useful for:
- prototyping new likelihood models,
- validating new observation/model compositions,
- and running smaller end-to-end inference problems without introducing an external orchestration layer.
Represents measured data and its covariance structure, including:
- statistical errors,
- systematic normalization errors,
- systematic offset errors,
- or fixed covariance matrices.
Maps model parameters to predicted observables for a given Observation.
Encodes how predictions are compared to observations. Built-in options include:
- Gaussian covariance-based likelihoods,
- unknown noise models,
- unknown normalization / normalization-error models,
- unknown model-error terms,
- Student-t likelihoods,
- and a Gaussian-process discrepancy model using sklearn kernels.
Pairs observations, a physical model, and a likelihood model.
Aggregates multiple independent constraints that share the same physical-model parameterization.
The examples/ directory contains richer notebooks and demos. The most useful
entry points are:
examples/linear_calibration_demo.ipynbfor the basic workflow,examples/systematic_err_demo.ipynbfor likelihood comparisons and systematic-error handling,examples/30s_optical_potential_calibration.ipynbfor a realistic optical potential calibration example,examples/normalization_inference.ipynbfor normalization-focused modeling,examples/sampling_algos.ipynbfor sampling comparisons.
Run the full validation matrix with:
python -m isort --check-only src test
python -m black --check src test
python -m ruff check src test
python -m nbqa isort --check examples/*.ipynb
python -m black --check --ipynb examples/*.ipynb
python -m nbqa ruff examples/*.ipynb
python -m pytestIf you want to apply the formatting fixes locally instead of only checking them:
python -m isort src test
python -m black src test
python -m ruff check --fix src test
python -m nbqa isort examples/*.ipynb
python -m black --ipynb examples/*.ipynb
python -m nbqa ruff --fix --unsafe-fixes examples/*.ipynbRun only the unit tests with:
python -m pytest testRun only the notebooks with:
python -m pytest examples