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

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.3 Sherpa v1


Context: fitting


Parses the goodness-of-fit statistic information returned by calc_stat_info()




The get_stat_info() function is available for parsing the output of the calc_stat_info() function, which returns the goodness-of-fit statistics associated with a data set and its assigned model (the CIAO 4.2 version of the GOODNESS function in CIAO 3.4). The advantage it offers over the get_fit_results() function is that it returns statistics on individual data sets included in a simultaneous fit, plus the statistics of the simultaneous fit, whereas get_fit_results() would only return the statistics of the simultaneous fit. The get_stat_info() function is useful for accessing and manipulating individual components of the calc_stat_info() structure, e.g. within a script, whereas calc_stat_info() is recommended for printing fit statistic information to the screen, at the Sherpa command line.

The get_stat_info() function returns the following information about how well the specified models fit the data:

  • name - name of data set
  • ids - data set ID number
  • bkg_ids - associated background data set ID number
  • statname - the chosen fit statistic
  • statval - fit statistic value
  • numpoints - number of bins in the fit
  • dof - the number of degrees of freedom in the fit, i.e. the number of bins minus the number of free parameters
  • qval - [only reported with chi-square and 'cstat' statistics] a measure of the (Q-value) probability that one would observe the reduced statistic value, or a larger value, if the assumed model is true and the best-fit model parameters are the true parameter values
  • rstat - [only reported with chi-square and 'cstat' statistics] fit statistic value divided by the number of degrees of freedom

This function accepts no arguments; it returns the fit statistics for all data sets which have been assigned models, including background data sets associated with source data sets. This means that if a fit has not yet been performed in the Sherpa session, calc_stat_info() will return not-very-meaningful statistics for data sets which have been assigned models but which have not yet been fit. Also, if a fit has been performed for only some of the data sets with assigned models, those data sets which were not explicitly fit will be included in the simultaneous fit results returned by calc_stat_info() (see an example of this behavior below in the examples section).

Example 1

sherpa> set_model(xsphabs.abs1*powlaw1d.p1)
sherpa> set_bkg_model("p1")
sherpa> fit()
sherpa> print get_stat_info()[0]
sherpa> print get_stat_info()[1]
sherpa> print get_stat_info()[2]

Return the statistics resulting from a simultaneous fit of the source and background spectra assigned to default data set 1. Print the goodness-of-fit statistics for each individual data set included in the fit, plus the simultaneous fit.

sherpa> print(get_stat_info()[0])
name      = Dataset 1
ids       = (1,)
bkg_ids   = None
statname  = chi2gehrels
statval   = 5506.18997409
numpoints = 1024
dof       = 1021
qval      = 0.0
rstat     = 5.39293827041

sherpa> print(get_stat_info()[1])
name      = Background 1 for Dataset 1
ids       = (1,)
bkg_ids   = (1,)
statname  = chi2gehrels
statval   = 15975.5866119
numpoints = 1024
dof       = 1022
qval      = 0.0
rstat     = 15.6316894441

sherpa-23> print(get_stat_info()[2])
name      = Dataset [1]
ids       = [1]
bkg_ids   = None
statname  = chi2gehrels
statval   = 21481.776586
numpoints = 2048
dof       = 2045
qval      = 0.0
rstat     = 10.5045362279

Example 2

sherpa> load_pha("source.pi")
sherpa> load_arf("arf1.fits")
sherpa> load_rmf("rmf1.fits")
sherpa> set_model("xsphabs.abs1*xspowerlaw.p1")
sherpa> subtract()
sherpa> fit()
sherpa> calc_stat_info()
sherpa> f=get_stat_info()[0]
sherpa> print(f.rstat)

The calc_stat_info() function is used to return the goodness-of-fit statistics resulting from the fit of an absorbed power law model to background-subtracted data set 1. The get_stat_info() function is used to parse this information and store the fit statistic information to variable "f"; "f" is then used in turn to access the reduced statistic value.

sherpa> calc_stat_info()
Dataset               = 1
Statistic             = chi2gehrels
Fit statistic value   = 703.792
Data points           = 1024
Degrees of freedom    = 1021
Probability [Q-value] = 1
Reduced statistic     = 0.689316

sherpa> f=get_stat_info()[0]

sherpa> print(f)
name      = Dataset [1]
ids       = [1]
bkg_ids   = None
statname  = chi2gehrels
statval   = 703.791857589
numpoints = 1024
dof       = 1021
qval      = 1.0
rstat     = 0.689316217031

sherpa> print(f.rstat)


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

See Also

get_conf, get_covar, get_int_proj, get_int_unc, get_proj, get_reg_proj, get_reg_unc
get_areascal, get_arf, get_arf_plot, get_axes, get_backscal, get_bkg, get_bkg_plot, get_bkg_scale, get_coord, get_counts, get_data, get_data_plot, get_dep, get_dims, get_error, get_exposure, get_grouping, get_indep, get_quality, get_rmf, get_specresp, get_staterror, get_syserror
calc_stat_info, get_fit
get_default_id, list_stats
get_iter_method_name, get_iter_method_opt, get_method
get_model, 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_response, get_source, get_source_component_image, get_source_component_plot, image_source
get_kernel, get_psf
get_chisqr_plot, get_delchi_plot, get_stat
get_analysis, get_rate
get_ratio, get_resid, image_getregion

Last modified: December 2010
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-2019. All rights reserved.