Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2013

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.10 Sherpa v1


Context: statistics


Define a prior function for a particular Sherpa model parameter.


set_prior(par, prior)


pyBLoCXS is a sophisticated Markov chain Monte Carlo (MCMC) based algorithm designed to carry out Bayesian Low-Count X-ray Spectral (BLoCXS) analysis in the Sherpa environment. The algorithm explores parameter space at a suspected minimum - i.e. after a standard Sherpa fit.

By default, pyBLoCXS uses a flat prior defined between the hardcoded parameter minima and maxima. The set_prior() function is used to associate a function or model ('prior') with a thawed fit parameter ('par'). The function signature for 'prior' is of the form lambda x, and can be a Sherpa model or an arbitrary user-defined function. The Sherpa prior functions constitute a subset of the pyBLoCXS suite of functions.

  • prior - prior function, of the form lambda x, associated with a Sherpa model parameter
  • par - Sherpa model parameter name

The list of currently set prior-parameter pairs is returned by the list_priors command. prior function associated with a particular Sherpa model parameter may be accessed with get_prior.

Refer to the pyBLoCXS documentation for additional information about the algorithm.


Example 1

set_prior(therm.kT, g1)

Define Gaussian model 'g1' using the Sherpa 'normgauss' model, and set it as the prior function for the temperature parameter of the Sherpa model 'xsapec.therm'.

sherpa> normgauss1d.g1
sherpa> g1.pos=2.5; g1.fwhm=0.5
sherpa> set_prior(therm.kT, g1)

sherpa> set_sampler_opt('defaultprior', False)
sherpa> set_sampler_opt('priorshape', [True, False, False])
sherpa> set_sampler_opt('originalscale', [True, True, True])

Example 2

set_prior(abs1.NH, lognorm)

Define custom function 'lognorm' and set it as the prior for the 'nH' parameter of a Sherpa absorption model.

def lognorm(x, sigma=0.5, norm=1.0, x0=20.):
   xl = numpy.log10(x)+22.
   return (norm/numpy.sqrt(2*numpy.pi)/sigma)*numpy.exp(-0.5*(xl-x0)*(xl-x0)/sigma/sigma)

set_sampler_opt('defaultprior', False)
set_sampler_opt('priorshape', [True, False, False])
set_sampler_opt('originalscale', [True, True, True])


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

See Also

set_conf_opt, set_covar_opt, set_proj_opt
set_areascal, set_arf, set_backscal, set_bkg, set_coord, set_counts, set_data, set_exposure, set_grouping, set_quality, set_rmf, set_staterror, set_syserror
set_iter_method, set_iter_method_opt, set_method, set_method_opt
get_par, set_bkg_model, set_full_model, set_par, set_pileup_model, set_source, set_xsabund, set_xscosmo, set_xsxsect, set_xsxset
cash, chi2constvar, chi2datavar, chi2gehrels, chi2modvar, chi2xspecvar, chisquare, cstat, get_prior, leastsq, list_priors, set_sampler, set_sampler_opt, set_stat, wstat
set_analysis, set_default_id

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.