Last modified: December 2015

Jump to: Description · Examples · Bugs · See Also

AHELP for CIAO 4.12 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 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:

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_source(xsphabs.abs1 * powlaw1d.p1)
sherpa> set_bkg_model("p1")
sherpa> fit()
sherpa> statinfo = get_stat_info()
sherpa> print(statinfo[0])
sherpa> print(statinfo[1])
sherpa> print(statinfo[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_source(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)


Use with the WStat statistic

The get_stat_info() routine fails with the message "StatErr: No background data has been supplied. Use cstat" when used with the wstat statistic.

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_chart_spectrum, get_marx_spectrum
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_draws, 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_prior, get_sampler, get_stat
get_analysis, get_rate
get_ratio, get_resid, image_getregion