Synopsis
Set the prior function to use with a parameter.
Syntax
set_prior(par, prior) par - a `Parameter` instance prior - function or sherpa.models.model.Model instance
Description
The default prior used by `get_draws` for each parameter is flat, varying between the soft minimum and maximum values of the parameter (as given by the `min` and `max` attributes of the parameter object). The `set_prior` function is used to change the form of the prior for a parameter, and `get_prior` returns the current prior for a parameter.
Examples
Example 1
Set the prior for the kt parameter of the therm component to be a gaussian, centered on 1.7 keV and with a FWHM of 0.35 keV:
>>> create_model_component('xsapec', 'therm') >>> create_model_component('gauss1d', 'p_temp') >>> p_temp.pos = 1.7 >>> p_temp.fwhm = 0.35 >>> set_prior(therm.kT, p_temp)
Example 2
Create a function ( lognorm ) and use it as the prior of the nh parameter of the abs1 model component:
>>> def lognorm(x): ... nh = 20 ... sigma = 0.5 # use a sigma of 0.5 ... # nH is in units of 10^-22 so convert ... dx = np.log10(x) + 22 - nh ... norm = sigma / np.sqrt(2 * np.pi) ... return norm * np.exp(-0.5 * dx * dx / (sigma * sigma)) ... >>> create_model_component('xsphabs', 'abs1') >>> set_prior(abs1.nH, lognorm)
PARAMETERS
The parameters for this function are:
Parameter | Definition |
---|---|
par | A parameter of a model instance. |
prior | The function to use for a prior. It must accept a single argument and return a value of the same size as the input. |
Bugs
See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.
See Also
- confidence
- set_conf_opt, set_covar_opt, set_proj_opt
- data
- set_areascal, set_arf, set_backscal, set_bkg, set_coord, set_counts, set_data, set_dep, set_exposure, set_grouping, set_quality, set_rmf, set_staterror, set_syserror
- filtering
- set_filter
- info
- list_stats
- methods
- get_draws, set_iter_method, set_iter_method_opt, set_method, set_method_opt
- modeling
- get_par, get_xsabund, get_xscosmo, get_xsxsect, get_xsxset, set_bkg_model, set_bkg_source, set_full_model, set_model, set_par, set_pileup_model, set_source, set_xsabund, set_xscosmo, set_xsxsect, set_xsxset
- statistics
- cash, chi2constvar, chi2datavar, chi2gehrels, chi2modvar, chi2xspecvar, chisquare, cstat, get_prior, leastsq, list_priors, set_sampler, set_sampler_opt, set_stat, wstat
- utilities
- set_analysis, set_default_id
- visualization
- image_setregion