Chandra X-Ray Observatory
Skip to the navigation links
Last modified: December 2013

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.10 Sherpa v1


Context: modeling


Sample the current set of thawed parameters from a uni-variate or multi-variate normal distribution.


normal_sample([num=1, sigma=1, correlate=True, id=None, otherids=(),


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.


  • 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

array([[  3.63429922e+01,   1.34294196e-02,   1.99111998e+00,

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,
       [  4.25527941e+01,   9.03353122e-03,   2.00151808e+00,
       [  3.61527980e+01,   2.04994375e-02,   2.03393790e+00,
       [  3.82226812e+01,   1.00899561e-02,   1.90617552e+00,

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.


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

See Also

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
get_arf_plot, get_bkg_plot
list_model_ids, show_bkg_model, show_bkg_source
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
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_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
delete_psf, load_conv, plot_kernel
save_delchi, save_resid
get_chisqr_plot, get_delchi_plot
calc_chisqr, calc_energy_flux, calc_model_sum, calc_photon_flux, calc_source_sum, calc_stat, eqwidth
contour_model, contour_ratio, contour_resid, get_ratio, get_resid

Last modified: December 2013
Smithsonian Institute Smithsonian Institute

The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory. 60 Garden Street, Cambridge, MA 02138 USA.   Email: Smithsonian Institution, Copyright © 1998-2017. All rights reserved.