CosmoFit.StoredSampler

class CosmoFit.StoredSampler(backend, metadata=None)[source]

Bases: object

A chain read back from disk, wearing the small part of the emcee.EnsembleSampler interface that CosmoFit actually asks of it.

That’s the point: Fitter.flat_samples(), .summary(), .convergence(), .best_fit(), plots.corner(), the derived-quantity posteriors and everything else read the sampler through get_chain/get_log_prob/nwalkers/iteration. Give them one of these instead of a live sampler and they work unchanged, on a chain that may have been sampled weeks ago in another process.

Read-only by construction – there is no run. To add steps to a stored chain, go back through Fitter.run_mcmc(save=..., nsteps=<a larger total>).

Parameters:
  • backend (emcee.backends.Backend) – Usually an HDFBackend opened read_only=True.

  • metadata (dict, optional) – The CosmoFit metadata stored with the chain.

__init__(backend, metadata=None)[source]

Methods

__init__(backend[, metadata])

flat_samples([burnin])

Post-burn-in samples, walkers flattened together -- the same array Fitter.flat_samples() returns.

get_autocorr_time(**kwargs)

get_chain(**kwargs)

get_last_sample()

get_log_prob(**kwargs)

samples_dict([burnin])

Flat samples as a dict of 1D arrays keyed by parameter name.

summary([burnin])

Posterior median +/- 68% interval per parameter, in the same shape as Fitter.summary() -- available here without constructing a Fitter at all, i.e. without reading a single dataset.

Attributes

acceptance_fraction

burnin

Burn-in recorded at sampling time, used as the default by the methods below.

free_params

Parameter names, from the stored metadata.

iteration

ndim

nwalkers

random_state