Uniform Prior, single observation

# sphinx_gallery_thumbnail_number = -1
import arviz as az
import matplotlib.pyplot as plt
import pyro
import torch

from gempy_probability.plot_posterior import PlotPosterior

from _aux_func import infer_model

az.style.use("arviz-doc")

y_obs = torch.tensor([2.12])
y_obs_list = torch.tensor([2.12, 2.06, 2.08, 2.05, 2.08, 2.09,
                           2.19, 2.07, 2.16, 2.11, 2.13, 1.92])
pyro.set_rng_seed(4003)
az_data = infer_model(
    distributions_family="uniform_distribution",
    data=y_obs
)

az.plot_trace(az_data)
plt.show()
$\mu_{likelihood}$, $\mu_{likelihood}$, $\sigma_{likelihood}$, $\sigma_{likelihood}$
Warmup:   0%|          | 0/1100 [00:00, ?it/s]
Warmup:   2%|▏         | 18/1100 [00:00, 175.21it/s, step size=1.65e-01, acc. prob=0.750]
Warmup:   3%|▎         | 36/1100 [00:00, 109.85it/s, step size=1.23e-01, acc. prob=0.768]
Warmup:   4%|▍         | 49/1100 [00:00, 103.10it/s, step size=8.03e-02, acc. prob=0.770]
Warmup:   5%|▌         | 60/1100 [00:00, 82.38it/s, step size=2.54e-02, acc. prob=0.765]
Warmup:   6%|▋         | 69/1100 [00:00, 59.05it/s, step size=1.06e-01, acc. prob=0.778]
Warmup:   8%|▊         | 85/1100 [00:01, 78.84it/s, step size=1.28e-01, acc. prob=0.782]
Sample:  10%|▉         | 105/1100 [00:01, 105.56it/s, step size=3.73e-01, acc. prob=0.868]
Sample:  12%|█▏        | 136/1100 [00:01, 153.71it/s, step size=3.73e-01, acc. prob=0.806]
Sample:  15%|█▍        | 164/1100 [00:01, 183.80it/s, step size=3.73e-01, acc. prob=0.704]
Sample:  17%|█▋        | 188/1100 [00:01, 198.61it/s, step size=3.73e-01, acc. prob=0.742]
Sample:  20%|██        | 223/1100 [00:01, 238.82it/s, step size=3.73e-01, acc. prob=0.706]
Sample:  23%|██▎       | 249/1100 [00:01, 223.47it/s, step size=3.73e-01, acc. prob=0.707]
Sample:  25%|██▌       | 278/1100 [00:01, 238.52it/s, step size=3.73e-01, acc. prob=0.717]
Sample:  28%|██▊       | 304/1100 [00:01, 243.78it/s, step size=3.73e-01, acc. prob=0.732]
Sample:  30%|███       | 330/1100 [00:01, 229.64it/s, step size=3.73e-01, acc. prob=0.754]
Sample:  32%|███▏      | 356/1100 [00:02, 235.60it/s, step size=3.73e-01, acc. prob=0.759]
Sample:  35%|███▍      | 381/1100 [00:02, 238.12it/s, step size=3.73e-01, acc. prob=0.763]
Sample:  37%|███▋      | 406/1100 [00:02, 231.60it/s, step size=3.73e-01, acc. prob=0.754]
Sample:  40%|███▉      | 437/1100 [00:02, 249.74it/s, step size=3.73e-01, acc. prob=0.757]
Sample:  42%|████▏     | 463/1100 [00:02, 225.79it/s, step size=3.73e-01, acc. prob=0.768]
Sample:  44%|████▍     | 489/1100 [00:02, 234.28it/s, step size=3.73e-01, acc. prob=0.778]
Sample:  47%|████▋     | 513/1100 [00:02, 227.41it/s, step size=3.73e-01, acc. prob=0.787]
Sample:  49%|████▉     | 540/1100 [00:02, 238.71it/s, step size=3.73e-01, acc. prob=0.789]
Sample:  52%|█████▏    | 568/1100 [00:02, 246.52it/s, step size=3.73e-01, acc. prob=0.790]
Sample:  54%|█████▍    | 594/1100 [00:03, 249.49it/s, step size=3.73e-01, acc. prob=0.797]
Sample:  56%|█████▋    | 621/1100 [00:03, 253.43it/s, step size=3.73e-01, acc. prob=0.796]
Sample:  59%|█████▉    | 647/1100 [00:03, 255.22it/s, step size=3.73e-01, acc. prob=0.798]
Sample:  61%|██████    | 673/1100 [00:03, 247.57it/s, step size=3.73e-01, acc. prob=0.805]
Sample:  63%|██████▎   | 698/1100 [00:03, 243.49it/s, step size=3.73e-01, acc. prob=0.808]
Sample:  66%|██████▌   | 726/1100 [00:03, 251.31it/s, step size=3.73e-01, acc. prob=0.802]
Sample:  68%|██████▊   | 752/1100 [00:03, 248.16it/s, step size=3.73e-01, acc. prob=0.807]
Sample:  71%|███████   | 777/1100 [00:03, 232.27it/s, step size=3.73e-01, acc. prob=0.807]
Sample:  73%|███████▎  | 804/1100 [00:03, 239.95it/s, step size=3.73e-01, acc. prob=0.799]
Sample:  75%|███████▌  | 829/1100 [00:04, 240.63it/s, step size=3.73e-01, acc. prob=0.803]
Sample:  78%|███████▊  | 856/1100 [00:04, 248.83it/s, step size=3.73e-01, acc. prob=0.805]
Sample:  81%|████████  | 892/1100 [00:04, 277.11it/s, step size=3.73e-01, acc. prob=0.791]
Sample:  84%|████████▍ | 923/1100 [00:04, 283.35it/s, step size=3.73e-01, acc. prob=0.788]
Sample:  89%|████████▉ | 980/1100 [00:04, 366.22it/s, step size=3.73e-01, acc. prob=0.747]
Sample:  92%|█████████▏| 1017/1100 [00:04, 363.18it/s, step size=3.73e-01, acc. prob=0.746]
Sample:  96%|█████████▌| 1054/1100 [00:04, 343.60it/s, step size=3.73e-01, acc. prob=0.741]
Sample:  99%|█████████▉| 1089/1100 [00:04, 300.17it/s, step size=3.73e-01, acc. prob=0.747]
Sample: 100%|██████████| 1100/1100 [00:04, 225.45it/s, step size=3.73e-01, acc. prob=0.746]

posterior predictive shape not compatible with number of chains and draws.This can mean that some draws or even whole chains are not represented.
p = PlotPosterior(az_data)

p.create_figure(figsize=(9, 5), joyplot=False, marginal=True, likelihood=True)
p.plot_marginal(
    var_names=['$\\mu_{likelihood}$', '$\\sigma_{likelihood}$'],
    plot_trace=False,
    credible_interval=1,
    kind='kde',
    joint_kwargs={'contour': True, 'pcolormesh_kwargs': {}},
    joint_kwargs_prior={'contour': False, 'pcolormesh_kwargs': {}}
)
p.axjoin.set_xlim(1.96, 2.22)
p.plot_normal_likelihood(
    mean='$\mu_{likelihood}$',
    std='$\sigma_{likelihood}$',
    obs='$y$',
    iteration=-6,
    hide_lines=True
)
p.likelihood_axes.set_xlim(1.70, 2.40)
plt.show()
Likelihood

License

The code in this case study is copyrighted by Miguel de la Varga and licensed under the new BSD (3-clause) license:

https://opensource.org/licenses/BSD-3-Clause

The text and figures in this case study are copyrighted by Miguel de la Varga and licensed under the CC BY-NC 4.0 license:

https://creativecommons.org/licenses/by-nc/4.0/ Make sure to replace the links with actual hyperlinks if you’re using a platform that supports it (e.g., Markdown or HTML). Otherwise, the plain URLs work fine for plain text.

Total running time of the script: (0 minutes 7.826 seconds)

Gallery generated by Sphinx-Gallery