Plotter
plot_predictive_coverage(solver, distribution='posterior', x_lim=None, y_lim=None, figsize=(12, 6), plot_background=False, plot_models=True, plot_components=True, legend=True, n_samples=100, min_counts=None, grouping=None, residual_kind='pearson')
Plot posterior predictive spectra with residuals.
The lower panel displays residuals between the observed data \(D\) and the sampled model predictions \(M_i\). Three formulae are available, selected via the residual_kind parameter:
- Pearson (
"pearson", default) — per-sample Poisson normalisation, well defined for both prior and posterior predictive checks:
- Sigma (
"sigma") — normalised by the 68 % ensemble spread; can be misleading when the prior is broad:
- Raw (
"raw") — un-normalised residuals in data units (counts / keV / s):
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
solver
|
Solver instance exposing |
required | |
distribution
|
str
|
Name of the distribution to sample from,
looked up in |
'posterior'
|
x_lim
|
tuple[float, float]
|
Energy bounds in keV for the upper panel x-axis. |
None
|
y_lim
|
tuple[float, float]
|
Flux limits for the upper panel y-axis. |
None
|
figsize
|
tuple[float, float]
|
Matplotlib figure size in
inches. Defaults to |
(12, 6)
|
plot_background
|
bool
|
Reserved for background overlays.
This currently has no effect unless the simulated payload contains a
|
False
|
plot_models
|
bool
|
If |
True
|
plot_components
|
bool
|
If |
True
|
legend
|
bool
|
Whether to display the legend on the spectrum
panel. Defaults to |
True
|
n_samples
|
int
|
Number of parameter draws used to build the
predictive bands. Defaults to |
100
|
min_counts
|
int
|
If set, adjacent bins are merged until every
grouped bin contains at least min_counts observed counts. The
same grouping is applied to all plotted quantities (observed
spectrum, models, components, and residuals). |
None
|
grouping
|
int
|
If set, every grouping adjacent bins are
merged into one (the last group may contain fewer bins). Mutually
exclusive with min_counts. Defaults to |
None
|
residual_kind
|
str
|
Formula used for the residual panel.
One of |
'pearson'
|
Returns:
| Type | Description |
|---|---|
|
matplotlib.figure.Figure: Figure containing spectrum and residual panels. |