Sampler#
jeanspy.sampler.Sampler
See methods and properties for individual lookup pages, or the alphabetical API dictionary to search all classes. The full class contract and existing member anchors are retained below.
- class jeanspy.sampler.Sampler(model, p0_generator, nwalkers=None, prefix='', reset=False, pool=None, wbic=False, **kwargs)[source]#
Bases:
objectwrapper class for emcee.EnsembleSampler
Notes
Inputs and units. model supplies posterior/blobs and parameter names;
p0_generatorprovides starting positions; nwalkers is an ensemble size; prefix sets output filename; reset=True deliberately resets the requested store; pool controls parallel evaluation.run_mcmcreceives the run length/options in its real signature.Returns and shape. HDF5 chain and diagnostic blobs;
get_chainreturns (draw,walker,parameter), or flattened draws.get_log_prob/get_blobsuse corresponding draw/walker axes.get_dataframereturns a pandas table.Validity. Workers share a stateful model only through the supported process/storage setup. Use independent ensembles for R-hat; interacting walkers are not independent chains.
Errors. Incompatible persisted analysis identity raises before continuing. Missing/malformed state, invalid parameter conversion or storage failures raise.
Backend. Python/emcee host sampler around NumPy/SciPy CPU likelihoods.
Differentiation. No physical-parameter automatic differentiation on this API.
Examples.
examples/docs_inference.py; complete tutorials for production diagnostics.- check_parameter_conversion(p0_generator=None)[source]#
check the conversion of parameters. This is useful to check if the parameters are properly converted from p0 to params. It will print the p0 and params and their comparison.
- set_wrapper_function()[source]#
Install the current log-probability callable in this worker process.
Returns None. The module-level wrapper lets multiprocessing workers evaluate their initialized model without repeatedly serializing it. This is host-side worker initialization, not a numerical solver.
- property filename#
Return the HDF5 backend’s filename.
- burn_in(nsteps, p0_generator, **kwargs)[source]#
Advance warmup and continue from its final ensemble.
Warmup draws remain in the backend. Exclude them explicitly with get_chain(discard=…) when analyzing production draws. The chain already samples the posterior and must not be weighted by the posterior density a second time.
- run_mcmc(iterations, loops, reset=False, p0_generator=None, enable_convergence_check=True, **kwargs)[source]#
run the sampler. p0 is generated by p0_generator. save and monitor the chain and lnprob using backends. blobs_dtype is obtained by model.
iterations: number of iterations for each loop loops: number of loops reset: discard the stored chain and initialize a new run p0_generator: override the constructor’s initial-state generator
- Parameters:
p0_generator (Callable | None)