    Set the prior function to use with a parameter.

set_prior(par, prior)
par - a `Parameter` instance
prior - function or sherpa.models.model.Model instance

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.

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)

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.

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

December 2023