get_pvalue_results
- sherpa.astro.ui.get_pvalue_results()
Return the data calculated by the last plot_pvalue call.
The
get_pvalue_results
function returns the likelihood ratio test results computed by theplot_pvalue
command, which compares fits of the null model to fits of the alternative model using faked data with Poisson noise. The likelihood ratio based on the observed data is returned, along with the p-value, used to reject or accept the null model.Changed in version 4.15.1: The parnames and parvals attributes have been added. They are intended to debug problem cases and so are not displayed by default.
- Returns:
plot – If
plot_pvalue
orget_pvalue_plot
have been called then the return value is asherpa.sim.simulate.LikelihoodRatioResults
instance, otherwiseNone
is returned.- Return type:
None or a
sherpa.sim.simulate.LikelihoodRatioResults
instance
See also
plot_value
Compute and plot a histogram of likelihood ratios by simulating data.
get_pvalue_plot
Return the data used by plot_pvalue.
Notes
The fields of the returned (
LikelihoodRatioResults
) object are:- ratios
The calculated likelihood ratio for each iteration.
- stats
The calculated fit statistics for each iteration, stored as the null model and then the alt model in a nsim by 2 array.
- samples
The parameter samples array for each simulation, stored in a nsim by npar array.
- lr
The likelihood ratio of the observed data for the null and alternate models.
- ppp
The p value of the observed data for the null and alternate models.
- null
The fit statistic of the null model on the observed data.
- alt
The fit statistic of the alternate model on the observed data.
- parnames
The names of the fitted parameters in the alternate model. This will be larger than the number of parameters returned in the samples field.
- parvals
The best-fit parameter values to the alternate model for each simulation, stored as a nsim by len(parnames) array.
Examples
Return the results of the last pvalue analysis and display the results - first using the
format
method, which provides a summary of the data, and then a look at the individual fields in the returned object. The last call displays the contents of one of the fields (ppp
).>>> res = get_pvalue_results() >>> print(res.format()) >>> print(res) >>> print(res.ppp)
Display the ratio values to check they look sensible (such as not dropping to a long range of 0’s, although this can also suggest the alternate model is not preferred to the null model):
>>> plot_trace(res.ratios, name="ratios")
Look at the cumulative distribution of the ratios:
>>> plot_cdf(res.ratios, name="ratios")
The parvals field shows the fitted parameter values for the alternate model at each iteration:
>>> plot_trace(res.parvals[:, 0], name=res.parnames[0]) >>> plot_trace(res.parvals[:, 1], name=res.parnames[1])