ed.ppc_stat_hist_plot

Aliases:

  • ed.criticisms.ppc_stat_hist_plot
  • ed.ppc_stat_hist_plot
ppc_stat_hist_plot(
    y_stats,
    yrep_stats,
    stat_name=None,
    **kwargs
)

Defined in edward/criticisms/ppc_plots.py.

Create histogram plot comparing data to samples from posterior.

Args:

  • y_stats: float. Float representing statistic value of observed data.
  • yrep_stats: np.ndarray. A 1-D NumPy array.
  • stat_name: string. Optional string value for including statistic name in legend. **kwargs: Keyword arguments used by seaborn.distplot can be given to customize plot.

Returns:

matplotlib axes.

Examples

import matplotlib.pyplot as plt

# DATA
x_data = np.array([0, 1, 0, 0, 0, 0, 0, 0, 0, 1])

# MODEL
p = Beta(1.0, 1.0)
x = Bernoulli(probs=p, sample_shape=10)

# INFERENCE
qp = Beta(tf.nn.softplus(tf.Variable(tf.random_normal([]))),
          tf.nn.softplus(tf.Variable(tf.random_normal([]))))

inference = ed.KLqp({p: qp}, data={x: x_data})
inference.run(n_iter=500)

# CRITICISM
x_post = ed.copy(x, {p: qp})
y_rep, y = ed.ppc(
    lambda xs, zs: tf.reduce_mean(tf.cast(xs[x_post], tf.float32)),
    data={x_post: x_data})

ed.ppc_stat_hist_plot(
    y[0], y_rep, stat_name=r'$T \equiv$mean', bins=10)
plt.show()