| AHELP for CIAO 4.5 Sherpa v1 | normal_sample |
Context: modeling |
Synopsis
Sample the current set of thawed parameters from a uni-variate or multi-variate normal distribution.
Syntax
normal_sample([num=1, sigma=1, correlate=True, id=None, otherids=(), numcores=None])
Description
Sherpa includes several functions for calculating the best set of best-fit model parameters, so to speak, for a given fit of a model to a data set, in order to best determine source flux using that model. This is done by sampling model parameter values, a specified number of times, from a given distribution such as a Gaussian distribution, in order to incorporate the uncertainties on model parameter values in the fit.
The normal_sample() function returns the fit statistic value per set of thawed model parameters sampled from the Gaussian uni-variate or multi-variate distribution, the former treating each parameter independently, the latter for correlated parameters. To sample from the uniform or Student's t-distribution, use the uniform_sample() or t_sample() functions.
All thawed model parameters are sampled from the Gaussian distribution, where the mean is set as the best-fit parameter value and the variance is determined by the diagonal elements of the covariance matrix. The multi-ivariate Gaussian is assumed by default for correlated parameters, using the off-diagonal elements of the covariance matrix.
Arguments:
- num - number of samples to calculate; default = 1
- sigma - spread of the normal distribution; default = 1
- correlate - if True, sample from multi-variate normal using covariance; if False, sample from uni-variate normal; default = True
- id - Sherpa data id; default = default data id
- otherids - list of other Sherpa data ids; default = ()
- numcores - number of CPUs to use to calculate the statistic; default = number of detected CPUs
The normal_sample() command returns an array table consisting of as many rows as samples taken (determined by the 'num' setting), with the calculated fit statistic values in the first column, and the corresponding sampled model parameters in the subsequent columns.
Example 1
load_pha("source.pi")
set_source(xsphabs.abs1*powlawd1d.p1)
normal_sample()
array([[ 3.63429922e+01, 1.34294196e-02, 1.99111998e+00,
1.93767611e-04]])
Call normal_sample() with default settings to return the fit statistic value and model parameter values resulting from the best fit of an absorbed power-law model to default data set 1, where all thawed parameters are considered to be correlated in the fit, and therefore sampled from a multi-variate Gaussian distribution.
Example 2
normal_sample(num=100, correlate=False, id=3)
array([[ 3.50450794e+01, 1.83813573e-02, 1.96399402e+00,
1.91009277e-04],
[ 4.25527941e+01, 9.03353122e-03, 2.00151808e+00,
1.89774746e-04],
...
[ 3.61527980e+01, 2.04994375e-02, 2.03393790e+00,
1.90969702e-04],
[ 3.82226812e+01, 1.00899561e-02, 1.90617552e+00,
1.89799097e-04]])
Return the fit statistic value and set of model parameter values resulting from the best fit of the model assigned to data set 3, for each of 100 samples. The samples are drawn from a uni-variate Gaussian distribution, where all thawed parameters are treated independently.
Bugs
See the bugs pages on the Sherpa website for an up-to-date listing of known bugs.
See Also
- contrib
- get_data_prof, get_data_prof_prefs, get_delchi_prof, get_delchi_prof_prefs, get_fit_prof, get_model_prof, get_model_prof_prefs, get_resid_prof, get_resid_prof_prefs, get_source_prof, get_source_prof_prefs, plot_chart_spectrum, prof_data, prof_delchi, prof_fit, prof_fit_delchi, prof_fit_resid, prof_model, prof_resid, prof_source
- data
- get_arf_plot, get_bkg_plot
- info
- list_model_ids, show_bkg_model, show_bkg_source
- modeling
- add_model, add_user_pars, clean, create_model_component, delete_bkg_model, delete_model, delete_model_component, get_model, get_model_autoassign_func, get_model_component, get_model_component_image, get_model_component_plot, get_model_plot, get_num_par, get_order_plot, get_par, get_pileup_model, get_source, get_source_component_image, get_source_component_plot, image_model, image_model_component, image_source, image_source_component, integrate, integrate1d, link, load_table_model, load_template_model, load_user_model, reset, save_model, save_source, set_bkg_model, set_full_model, set_model_autoassign_func, set_pileup_model, set_source, set_xsabund, set_xscosmo, set_xsxsect, set_xsxset, t_sample, uniform_sample
- plotting
- get_energy_flux_hist, get_lrt_plot, get_lrt_results, get_photon_flux_hist, get_pvalue_plot, get_pvalue_results, get_split_plot, plot, plot_arf, plot_bkg, plot_cdf, plot_chisqr, plot_data, plot_delchi, plot_energy_flux, plot_fit, plot_lrt, plot_model, plot_model_component, plot_order, plot_pdf, plot_photon_flux, plot_pvalue, plot_ratio, plot_resid, plot_scatter, plot_source, plot_source_component, plot_trace, set_xlinear, set_xlog, set_ylinear, set_ylog
- psfs
- delete_psf, load_conv, plot_kernel
- saving
- save_delchi, save_resid
- statistics
- get_chisqr_plot, get_delchi_plot
- utilities
- calc_chisqr, calc_energy_flux, calc_model_sum, calc_photon_flux, calc_source_sum, calc_stat, eqwidth
- visualization
- contour_model, contour_ratio, contour_resid, get_ratio, get_resid

![[Sherpa Logo]](../imgs/sherpa_logo_navbar.gif)