    Run the pyBLoCXS MCMC algorithm.

get_draws(id=None, otherids=(), niter=1000, covar_matrix=None)
id - int or str, optional
otherids - sequence of int or str, optional
niter - int, optional
covar_matrix - 2D array, optional

The function runs a Markov Chain Monte Carlo (MCMC) algorithm designed to carry out Bayesian Low-Count X-ray Spectral (BLoCXS) analysis. It explores the model parameter space at the suspected statistic minimum (i.e. after using `fit` ). The return values include the statistic value, parameter values, and an acceptance flag indicating whether the row represents a jump from the current location or not. For more information see the

`sherpa.sim` module and the reference given below.

Fit a source and then run a chain to investigate the parameter distributions. The distribution of the stats values created by the chain is then displayed, using `plot_trace` , and the parameter distributions for the first two thawed parameters are displayed. The first one as a cumulative distribution using `plot_cdf` and the second one as a probability distribution using `plot_pdf` . Finally the acceptance fraction (number of draws where the chain moved) is displayed. Note that in a full analysis session a burn-in period would normally be removed from the chain before using the results.

>>> fit() >>> covar() >>> stats, accept, params = get_draws(1, niter=1e4) >>> plot_trace(stats, name='stat') >>> names = [p.fullname for p in get_source().pars if not p.frozen] >>> plot_cdf(params[0,:], name=names[0], xlabel=names[0]) >>> plot_pdf(params[1,:], name=names[1], xlabel=names[1]) >>> accept[:-1].sum() * 1.0 / len(accept - 1) 0.4287

The following runs the chain on multiple data sets, with identifiers 'core', 'jet1', and 'jet2':

>>> stats, accept, params = get_draws('core', ['jet1', 'jet2'], niter=1e4)

PARAMETERS

The parameters for this function are:

Parameter
Definition
id
The data set that provides the data. If not given then all data sets with an associated model are used simultaneously.
otherids
Other data sets to use in the calculation.
niter
The number of draws to use. The default is 1000 .
covar_matrix
The covariance matrix to use. If none then the result from `get_covar_results().extra_output` is used.

The return value from this function is:

The results of the MCMC chain. The stats and accept arrays contain niter+1 elements, with the first row being the starting values. The params array has (nparams, niter+1)

elements, where nparams is the number of free parameters in the model expression, and the first column contains the values that the chain starts at. The accept array contains boolean values, indicating whether the jump, or step, was accepted ( True ), so the parameter values and statistic change, or it wasn't, in which case there is no change to the previous row. The `sherpa.utils.get_error_estimates`

routine can be used to calculate the credible one-sigma interval from the params array.

Notes

The chain is run using fit information associated with the specified data set, or sets, the currently set sampler ( `set_sampler` ) and parameter priors ( `set_prior` ), for a specified number of iterations. The model should have been fit to find the best-fit parameters, and `covar` called, before running `get_draws` . The results from `get_draws` is used to estimate the parameter distributions.

The `set_rng` routine is used to control how the random numbers are generated.

References

"Analysis of Energy Spectra with Low Photon Counts via Bayesian Posterior Simulation", van Dyk, D.A., Connors, A., Kashyap, V.L., & Siemiginowska, A. 2001, Ap.J., 548, 224

See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.

December 2023