sheap.MasterSampler.Samplers.McMcSampler module
MCMC Sampler (NumPyro)
This module provides the McMcSampler, a wrapper around
numpyro.infer.MCMC + NUTS for sampling posterior distributions of
spectral fit parameters.
Main Features
Interfaces directly with a
MasterSamplerestimator (after a fit has been run).Prepares normalized spectra, constraints, and parameter dictionaries for NumPyro.
Builds a model function via
make_numpyro_model().Runs Hamiltonian Monte Carlo (No-U-Turn Sampler).
Reconstructs full parameter vectors from sampled free parameters, applying tied and fixed constraints.
Rescales amplitude/log-amplitude parameters back into original units.
Wraps posterior samples into physical quantities using
SheaProducts.
Public API
McMcSampler:McMcSampler.sample_params()— run the sampler for one or more spectra, returning posterior parameter dictionaries.
Notes
Dependencies (ties/fixes) are enforced via
sheap.Assistants.parser_mapper.apply_tied_and_fixed_params().By default, each parameter is renamed to
theta_Nfor NumPyro’s sampler to avoid issues with long names.Internally uses JAX PRNG keys;
n_randomandkey_seedcan be used to control reproducibility.
- class McMcSampler(estimator)[source]
Bases:
object- Parameters:
estimator (MasterSampler)