Synopsis
Run the pyBLoCXS MCMC algorithm.
Syntax
get_draws(id=None, otherids=(), niter=1000, covar_matrix=None)
Description
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.
Examples
Example 1
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
Example 2
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 | Type information | Definition |
---|---|---|
id | int, str, or None, optional | The data set that provides the data. If not given then all data sets with an associated model are used simultaneously. |
otherids | sequence of int or str, optional | Other data sets to use in the calculation. |
niter | int, optional | The number of draws to use. The default is 1000 . |
covar_matrix | 2D array, optional | The covariance matrix to use. If none then the result from `get_covar_results().extra_output` is used. |
Return value
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
Bugs
See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.
See Also
- confidence
- get_conf, get_conf_results, get_covar, get_covar_opt, get_covar_results, get_covariance_results, get_int_proj, get_int_unc, get_proj, get_proj_opt, get_proj_results, get_projection_results, get_reg_proj, get_reg_unc
- contrib
- get_chart_spectrum, get_marx_spectrum
- data
- get_areascal, get_arf, get_arf_plot, get_axes, get_backscal, get_bkg, get_bkg_arf, get_bkg_chisqr_plot, get_bkg_delchi_plot, get_bkg_fit_plot, get_bkg_model, get_bkg_model_plot, get_bkg_plot, get_bkg_ratio_plot, get_bkg_resid_plot, get_bkg_rmf, get_bkg_scale, get_bkg_source, get_bkg_source_plot, get_coord, get_counts, get_data, get_data_contour, get_data_contour_prefs, get_data_image, get_data_plot, get_data_plot_prefs, get_dep, get_dims, get_error, get_exposure, get_grouping, get_indep, get_quality, get_rmf, get_specresp, get_staterror, get_syserror
- filtering
- get_filter
- fitting
- calc_stat_info, get_stat_info
- info
- get_default_id, list_stats
- methods
- get_iter_method_name, get_iter_method_opt, get_method, get_method_name, get_method_opt
- modeling
- get_model, get_model_component, get_model_component_image, get_model_component_plot, get_model_plot, get_num_par, get_num_par_frozen, get_num_par_thawed, get_order_plot, get_par, get_pileup_model, get_response, get_source, get_source_component_image, get_source_component_plot, get_source_contour, get_source_image, get_source_plot, image_source
- plotting
- get_split_plot, plot_cdf, plot_pdf, plot_trace
- psfs
- get_psf, get_psf_contour, get_psf_image, get_psf_plot
- statistics
- get_chisqr_plot, get_delchi_plot, get_prior, get_sampler, get_stat, get_stat_name, set_prior, set_sampler
- utilities
- get_analysis, get_rate
- visualization
- image_getregion