Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add a parameter to enable/disable smoothing on discrete variables in BLV (Issue #2325) #2344

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion arviz/plots/backends/matplotlib/bpvplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def plot_bpv(
plot_ref_kwargs,
backend_kwargs,
show,
smoothing,
):
"""Matplotlib bpv plot."""
if backend_kwargs is None:
Expand Down Expand Up @@ -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":
Expand Down
6 changes: 5 additions & 1 deletion arviz/plots/bpvplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -148,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
-------
Expand All @@ -166,7 +169,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
--------
Expand Down Expand Up @@ -291,6 +294,7 @@ def plot_bpv(
plot_ref_kwargs=plot_ref_kwargs,
backend_kwargs=backend_kwargs,
show=show,
smoothing=smoothing,
)

# TODO: Add backend kwargs
Expand Down
Loading