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 MasterSampler estimator (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

Notes

  • Dependencies (ties/fixes) are enforced via sheap.Assistants.parser_mapper.apply_tied_and_fixed_params().

  • By default, each parameter is renamed to theta_N for NumPyro’s sampler to avoid issues with long names.

  • Internally uses JAX PRNG keys; n_random and key_seed can be used to control reproducibility.

class McMcSampler(estimator)[source]

Bases: object

Parameters:

estimator (MasterSampler)

sample_params(num_samples=2000, num_warmup=500, summarize=True, n_random=1000, list_of_objects=None, key_seed=0)[source]
Parameters:
  • num_samples (int)

  • num_warmup (int)

  • key_seed (int)