API Reference#

Configuration#

High-level configuration objects for assembling a calibration problem and handing it to an external sampler (emcee, dynesty, etc.).

rxmc.config.CalibrationConfig

End-to-end configuration for Bayesian calibration.

rxmc.config.ParameterConfig

Configuration for a single sector of parameters.

Priors#

Prior distribution classes that satisfy the generic prior protocol required by ParameterConfig. Any user-defined class with logpdf, rvs, and (optionally) prior_transform methods can be used directly.

rxmc.priors.IndependentPrior

Independent prior built from an arbitrary list of scipy.stats distributions.

rxmc.priors.TruncatedNormalPrior

Independent truncated-normal prior for a vector of parameters.

Core building blocks#

rxmc.constraint.Constraint

Pair observations with a physical model and a stacked covariance.

rxmc.evidence.Evidence

A collection of independent constraints sharing a common physical model.

rxmc.observation.Observation

Experimental data: x, y, and the statistical error on y.

rxmc.params.Parameter

A single scalar model parameter.

rxmc.physical_model.PhysicalModel

Abstract base class for parametric physical models.

rxmc.physical_model.Polynomial

Polynomial model of fixed order.

Transforms#

One low-level, numpy-style transform type shared by observations (the comparison space, e.g. transform=log), models (parametric transforms such as a latent normalisation) and covariance terms (coordinate transforms).

rxmc.transforms.Transform

A numpy-style transform with optional parameters.

rxmc.transforms.as_transform

Coerce None (identity), a callable, or a Transform.

rxmc.transforms.identity

A numpy-style transform with optional parameters.

rxmc.transforms.log

Natural log; -inf (no warnings) where the argument is not positive.

rxmc.transforms.exp

A numpy-style transform with optional parameters.

rxmc.transforms.scale

A latent multiplicative normalisation \(\rho\, y\).

rxmc.transforms.per_observation_scaling

One latent normalisation \(\rho_i\) per dataset, routed by identity.

Covariance terms#

The stacked covariance of a Constraint is assembled additively from Term objects — a single generic type: a numpy-style callable of a TermContext (the term’s local x/y/ym) and its parameters, plus a kind ("diag"/"mode"/"matrix"). The factory helpers build the common terms in one line; anything else is a direct Term(fn, params, kind=...). A StackContext bundles the stacked x/y/ym that a ConstraintCovariance is evaluated on.

rxmc.covariance.Term

One additive contribution to the stacked covariance.

rxmc.covariance.TermContext

A term's local view of the stack on its own support.

rxmc.covariance.statistical_term

Always-on, genuinely uncorrelated statistical diagonal diag(stat_err**2).

rxmc.covariance.normalization_term

A correlated normalisation systematic outer(eta * ym, eta * ym).

rxmc.covariance.offset_term

A correlated absolute-offset systematic outer(omega, omega).

rxmc.covariance.noise_term

Unknown statistical noise diag((epsilon * basis)**2).

rxmc.covariance.noise_fraction_term

Unknown fractional noise diag((epsilon * ym)**2).

rxmc.covariance.model_error_term

Unknown uncorrelated model error diag((gamma * z)**2).

rxmc.covariance.systematic_term

A correlated mode outer(s * u, s * u) with a user basis u = basis(c, ...).

rxmc.covariance.kernel_term

A Gaussian-process kernel a a^T * K(x, x; theta) over the support.

rxmc.covariance.ones

Constant unit basis.

rxmc.covariance.ym

The model prediction — the prediction-scaled basis.

rxmc.covariance.averaging

0.5 * (y + ym) — the averaging model-error basis.

rxmc.covariance.x_basis

Basis x / scale (e.g. x_basis(np.pi) for theta/180 on radians).

rxmc.covariance.exp_growth

Parametric basis base(c) * exp(slope * x / scale).

rxmc.covariance.constant_amplitude

Kernel amplitude exp(log_amplitude), constant over the support.

rxmc.covariance.exp_growth_amplitude

Kernel amplitude exp(log_amplitude) * exp(slope * x / scale) (two params).

rxmc.covariance.stacked_supports

One contiguous index array per observation, in stacking order.

rxmc.covariance.ConstraintCovariance

The stacked covariance of a constraint, assembled from Term s.

rxmc.covariance.StackContext

Bundle of stacked arrays passed to every Term.add_to().

Likelihood functionals#

Thin functionals of the pre-computed Mahalanobis statistics (d2, logdet, n); all covariance modeling lives on the ConstraintCovariance.

rxmc.likelihood_model.Likelihood

A functional of the pre-computed Mahalanobis statistics (d2, logdet, n).

rxmc.likelihood_model.GaussianLikelihood

Multivariate-normal likelihood over the stacked residual.

rxmc.likelihood_model.StudentT

Multivariate Student-t likelihood with a degrees-of-freedom parameter.

rxmc.likelihood_model.Chi2

Generalised chi-squared functional — drops the log-det normalisation.

rxmc.likelihood_model.mahalanobis_distance_sqr_cholesky

Squared Mahalanobis distance and log-determinant via Cholesky factorisation.

rxmc.likelihood_model.log_likelihood

Multivariate-normal log likelihood from pre-computed statistics.

Predictive utilities#

Posterior-predictive helpers, including Gaussian-process discrepancy propagation.

rxmc.predictive.predictive_band

Percentile band over a matrix of predictive draws.

rxmc.predictive.gp_posterior_predictive

Posterior mean and covariance of a GP discrepancy at X_pred.

rxmc.predictive.total_predictive_band

Data-space predictive band that propagates total uncertainty.

Model comparison#

Sampler-agnostic posterior-predictive checks, held-out scoring, and nested-sampling evidence bookkeeping.

rxmc.model_comparison.predictive_draws

Posterior-predictive draws on the constraint's active points.

rxmc.model_comparison.coverage_curve

Empirical coverage of central predictive intervals at each nominal level.

rxmc.model_comparison.coverage_error

max |coverage(level) - level| — a single calibration score.

rxmc.model_comparison.sharpness

Per-point width of a central predictive interval.

rxmc.model_comparison.heldout_log_predictive

log p(y_held | theta_i) for each posterior row.

rxmc.model_comparison.log_posterior_predictive

log E_post[p(y_held | theta)]: the joint log posterior predictive density of the held-out block.

rxmc.model_comparison.logz_summary

Replicate-aware evidence summary.

rxmc.model_comparison.compare_logz

Delta log Z = a - b with a conservative tie verdict.

rxmc.model_comparison.log_jacobian

Comparison-space log-Jacobian of a constraint (sum over active points).

rxmc.model_comparison.split_samples

Split flat sampler rows into (model_samples, [cov_samples, ...]).

Sampling#

rxmc.walker.Walker

Gibbs-style MCMC coordinator for a Bayesian calibration problem.

rxmc.param_sampling.Sampler

Base class wrapping a sampling algorithm with chain recording.

rxmc.param_sampling.MetropolisHastingsSampler

Metropolis-Hastings sampler with a fixed proposal distribution.

rxmc.param_sampling.AdaptiveMetropolisSampler

Metropolis sampler that adapts the proposal covariance with a sliding window.

rxmc.param_sampling.BatchedAdaptiveMetropolisSampler

Metropolis sampler that updates the proposal covariance after each batch.

rxmc.proposal.ProposalDistribution

Abstract base class for Metropolis-Hastings proposal distributions.

rxmc.proposal.NormalProposalDistribution

Multivariate-normal proposal centred at the current state.

rxmc.proposal.HalfNormalProposalDistribution

Half-normal proposal, useful for strictly non-negative parameters.

rxmc.proposal.LogspaceNormalProposalDistribution

Normal proposal operating in log space, for strictly positive parameters.

Sampling algorithms#

Low-level sampling functions used internally by the sampler classes.

rxmc.metropolis_hastings.metropolis_hastings

Metropolis-Hastings MCMC sampling.

rxmc.adaptive_metropolis.adaptive_metropolis

Adaptive Metropolis algorithm with sliding-window covariance adaptation.

Domain-specific models#

Reaction-physics observation and model classes for elastic differential cross sections and isobaric-analog (p,n) cross sections.

rxmc.elastic_diffxs_observation.ElasticDifferentialXSObservation

Observation for elastic differential cross sections.

rxmc.elastic_diffxs_observation.momentum_transfer

Momentum transfer \(q = 2k\sin(\theta/2)\) (fm^-1) on the data angles.

rxmc.elastic_diffxs_model.ElasticDifferentialXSModel

A model that predicts the elastic differential xs for a given reaction.

rxmc.ias_pn_observation.IsobaricAnalogPNObservation

Observation for (p,n) isobaric analog state (IAS) reactions.

rxmc.ias_pn_model.IsobaricAnalogPNXSModel

A model that predicts the (p,n) IAS differential xs for a given reaction.