normal_sample
- sherpa.sim.sample.normal_sample(fit: Fit, num: int = 1, scale: float = 1, correlate: bool = True, numcores: int | None = None, rng: Generator | RandomState | None = None, clip: Literal['none', 'hard', 'soft'] = 'none') ndarray[source] [edit on github]
Sample the fit statistic by taking the parameter values from a normal distribution.
For each iteration (sample), change the thawed parameters by drawing values from a uni- or multi-variate normal (Gaussian) distribution, and calculate the fit statistic.
Changed in version 4.18.0: The sigma parameter has been renamed to scale, and the code has been updated so that changing it will change the sampled values. The clip parameter has been added, and the return value contains an extra column indicating whether a parameter in the row was clipped.
Changed in version 4.16.0: The rng parameter was added.
- Parameters:
- fit
The fit results.
- num
int,optional The number of samples to use (default is
1).- scale
number,optional Scale factor applied to the sigma values from the fit before sampling the normal distribution.
- correlatebool,
optional Should a multi-variate normal be used, with parameters set by the covariance matrix (
True) or should a uni-variate normal be used (False)?- numcores
optional The number of CPU cores to use. The default is to use all the cores on the machine.
- rng
numpy.random.Generator,numpy.random.RandomState,orNone,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:
samplesA 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.
See also
t_sampleSample from the Student’s t-distribution.
uniform_sampleSample from a uniform distribution.
Notes
It is expected that the model has already been fit to the data.
All thawed model parameters are sampled from the Gaussian distribution. The mean is set as the current parameter values. The variance is calculated from the covariance matrix of the fit multiplied by scale * scale. When correlate is False the diagonal of the matrix is used, so the parameters are uncorrelated. When correlate is True the full matrix is used, allowing for correlations between the parameters.