From 4af2e43d5b2e7650e90334966d35ba1d3b73037a Mon Sep 17 00:00:00 2001 From: Patchouli-Kenntnis <89133215+Patchouli-Kenntnis@users.noreply.github.com> Date: Mon, 8 Apr 2024 06:11:10 +0200 Subject: [PATCH 1/2] Add smoothing parameter --- arviz/plots/backends/matplotlib/bpvplot.py | 3 ++- arviz/plots/bpvplot.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arviz/plots/backends/matplotlib/bpvplot.py b/arviz/plots/backends/matplotlib/bpvplot.py index 3a4e55c7b8..e58ec04e8f 100644 --- a/arviz/plots/backends/matplotlib/bpvplot.py +++ b/arviz/plots/backends/matplotlib/bpvplot.py @@ -38,6 +38,7 @@ def plot_bpv( plot_ref_kwargs, backend_kwargs, show, + smoothing, ): """Matplotlib bpv plot.""" if backend_kwargs is None: @@ -87,7 +88,7 @@ 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": + if (obs_vals.dtype.kind == "i" or pp_vals.dtype.kind == "i") and smoothing == True: obs_vals, pp_vals = smooth_data(obs_vals, pp_vals) if kind == "p_value": diff --git a/arviz/plots/bpvplot.py b/arviz/plots/bpvplot.py index f7f869105b..004cd323a7 100644 --- a/arviz/plots/bpvplot.py +++ b/arviz/plots/bpvplot.py @@ -36,6 +36,7 @@ def plot_bpv( backend_kwargs=None, group="posterior", show=None, + smoothing=True, ): r"""Plot Bayesian p-value for observed data and Posterior/Prior predictive. @@ -166,7 +167,7 @@ def plot_bpv( Notes ----- Discrete data is smoothed before computing either p-values or u-values using the - function :func:`~arviz.smooth_data` + function :func:`~arviz.smooth_data` if the data is integer type and the smoothing parameter is True(by default). Examples -------- @@ -291,6 +292,7 @@ def plot_bpv( plot_ref_kwargs=plot_ref_kwargs, backend_kwargs=backend_kwargs, show=show, + smoothing=smoothing, ) # TODO: Add backend kwargs From e353532c7e67e4c89460891a47161347c2d6a2a5 Mon Sep 17 00:00:00 2001 From: Patchouli-Kenntnis <89133215+Patchouli-Kenntnis@users.noreply.github.com> Date: Mon, 8 Apr 2024 06:13:51 +0200 Subject: [PATCH 2/2] doc --- arviz/plots/bpvplot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arviz/plots/bpvplot.py b/arviz/plots/bpvplot.py index 004cd323a7..578b19d03f 100644 --- a/arviz/plots/bpvplot.py +++ b/arviz/plots/bpvplot.py @@ -149,6 +149,8 @@ def plot_bpv( the same comparison happens, but with the values in `prior_predictive` group. show : bool, optional Call backend show function. + smoothing : bool, default True + If True, smooth the data before computing the p-values or u-values. Returns -------