uniform_sample
- sherpa.astro.ui.uniform_sample(num: int = 1, factor: float = 4, id: IdType | None = None, otherids: IdTypes = (), numcores: int | None = None, clip: ClipValue = 'none') np.ndarray
Sample the fit statistic by taking the parameter values from an uniform distribution.
For each iteration (sample), change the thawed parameters by drawing values from a uniform distribution, and calculate the fit statistic.
Changed in version 4.18.0: The random state returned by get_rng is now used for the sampling. The clip parameter has been added, and the return array now ends in a column indicating whether any parameter in the row was clipped.
- Parameters:
num (int, optional) – The number of samples to use (default is 1).
factor (number, optional) – Multiplier to expand the scale parameter (default is 4).
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.
numcores (optional) – The number of CPU cores to use. The default is to use all the cores on the machine.
clip ({'hard', 'soft', 'none'}, optional) – What clipping strategy should be applied to the sampled parameters. The default (‘none’) applies no clipping, ‘hard’ uses the hard parameter limits, and ‘soft’ the soft limits.
- Returns:
A NumPy array table with the first column representing the statistic, the later columns the parameters used, and the last column indicating whether any parameter in the row was clipped. The number of rows is given by the num argument.
- Return type:
See also
fitFit a model to one or more data sets.
normal_sampleSample from a normal distribution.
set_modelSet the source model expression for a data set.
set_statSet the statistical method.
t_sampleSample from the Student’s t-distribution.
Examples
The model fit to the default data set has three free parameters. The median value of the statistic calculated by
uniform_sampleis returned:>>> ans = uniform_sample(num=1000) >>> ans.shape (1000, 5) >>> np.median(ans[:,0]) 284.66534775948134