Skip to content

Commit

Permalink
plot_bpv smooth discrete for both u_values and p_values (#2299)
Browse files Browse the repository at this point in the history
* smooth all

* add note
  • Loading branch information
aloctavodia authored Dec 22, 2023
1 parent 6b1b2be commit 27b8a49
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arviz/plots/backends/matplotlib/bpvplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ def plot_bpv(
obs_vals = obs_vals.flatten()
pp_vals = pp_vals.reshape(total_pp_samples, -1)

if obs_vals.dtype.kind == "i" or pp_vals.dtype.kind == "i":
obs_vals, pp_vals = smooth_data(obs_vals, pp_vals)

if kind == "p_value":
tstat_pit = np.mean(pp_vals <= obs_vals, axis=-1)
x_s, tstat_pit_dens = kde(tstat_pit)
Expand All @@ -110,9 +113,6 @@ def plot_bpv(
ax_i.plot(x_ss, u_dens, linewidth=linewidth, **plot_ref_kwargs)

elif kind == "u_value":
if obs_vals.dtype.kind == "i" or pp_vals.dtype.kind == "i":
obs_vals, pp_vals = smooth_data(obs_vals, pp_vals)

tstat_pit = np.mean(pp_vals <= obs_vals, axis=0)
x_s, tstat_pit_dens = kde(tstat_pit)
ax_i.plot(x_s, tstat_pit_dens, color=color)
Expand Down
5 changes: 5 additions & 0 deletions arviz/plots/bpvplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def plot_bpv(
----------
* Gelman et al. (2013) see http://www.stat.columbia.edu/~gelman/book/ pages 151-153 for details
Notes
-----
Discrete data is smoothed before computing either p-values or u-values using the
function :func:`smooth_data`
Examples
--------
Plot Bayesian p_values.
Expand Down

0 comments on commit 27b8a49

Please sign in to comment.