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 Student's t-distribution.


t_sample([num=1, dof=None, id=None, otherids=(), numcores=None])


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 t_sample() function returns the fit statistic value per set of thawed model parameters sampled from the Student's t-distribution. To sample from the Gaussian or uniform distribution, use the normal_sample() or uniform_sample() function.


  • num - number of samples to calculate; default = 1
  • dof - number of degrees of freedom, calculated from current fit by default; default = None
  • 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 t_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([[  7.42052409e+01,   2.19304497e-02,   2.07296817e+00,

Call t_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 sampled from the Student's t-distribution.

Example 2

t_sample(num=200, id=4, numcores=3)
array([[  3.67613474e+01,   2.02327747e-02,   1.94780376e+00,
       [  3.67961761e+01,   1.76162104e-02,   1.94484171e+00,

       [  3.52175590e+01,   1.78847675e-02,   1.99037247e+00,
       [  3.54881367e+01,   1.49198878e-02,   2.00103062e+00,

Return the fit statistic value and set of model parameter values resulting from the best fit of the model assigned to data set 4, for each of 200 samples drawn from the t-distribution. Utilize 2 CPUS in the fitting to reduce the computation time.


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, normal_sample, 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, 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.