NormalSampleFromScaleVector
- class sherpa.sim.sample.NormalSampleFromScaleVector[source] [edit on github]
Bases:
NormalParameterSampleFromScaleVectorUse a normal distribution to sample statistic and parameters (uncorrelated),
The parameters are drawn from a normal distribution based on the parameter errors, and do not include any correlations between the parameters. The errors will be generated from the fit object or specified directly as a covariance matrix.
Methods Summary
clip(fit, samples[, clip])Clip the samples if out of bounds.
get_sample(fit, *[, num, numcores, rng, clip])Return the statistic and parameter samples.
Methods Documentation
- clip(fit: Fit, samples: ndarray, clip: Literal['none', 'hard', 'soft'] = 'none') ndarray [edit on github]
Clip the samples if out of bounds.
- Parameters:
fit (sherpa.fit.Fit instance) – Contains the thawed parameters used to generate the samples.
samples (2D numpy array) – The samples array, stored as a n by npar matrix. This array is changed in place.
clip ({'none', 'hard', 'soft'} optional) – How should the values be clipped? The default (‘none’) has no clipping. The other methods restrict the values to lie within the hard or soft limits of the parameters.
- Returns:
clipped – A 1D boolean array indicating whether any sample in a row was clipped. Note that the input samples array will have been updated if any element in clipped is True.
- Return type:
1D numpy array
- get_sample(fit: Fit, *, num: int = 1, numcores: int | None = None, rng: Generator | RandomState | None = None, clip: Literal['none', 'hard', 'soft'] = 'none') ndarray[source] [edit on github]
Return the statistic and parameter samples.
Changed in version 4.18.0: The clip argument has been added, and the return value now has an extra column, indicating if the row was clipped.
Changed in version 4.16.0: All arguments but the first one must be passed as a keyword argument. The rng parameter was added.
- Parameters:
fit (sherpa.fit.Fit instance) – This defines the thawed parameters that are used to generate the samples, along with any possible error analysis.
num (int, optional) – The number of samples to return.
numcores (int or None, optional) – Should the calculation be done on multiple CPUs? The default (None) is to rely on the parallel.numcores setting of the configuration file.
rng (numpy.random.Generator, numpy.random.RandomState, or None, optional) – Determines how random numbers are created. If set to None then the routines from
numpy.randomare used, and so can be controlled by callingnumpy.random.seed.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:
samples – The array is num by (npar + 2) size, where npar is the number of free parameters in the fit argument. The first element in each row is the statistic value, the remaining are the parameter values, and then the last column indicates whether any parameters were clipped.
- Return type:
2D numpy array