如何可视化两个分布

时间:2018-12-17 15:02:24

标签: python plot scipy statistics distribution

我正在做MCMC,我有两个发行版:

from scipy.stats import lognorm
from scipy.stats import uniform
import numpy as np
prior_fb = uniform(loc=0, scale=0.1)
post_fb = lognorm(s=np.log(1.15), scale=0.0076)

如何比较同一图中的先验分布和后验分布?

1 个答案:

答案 0 :(得分:3)

from scipy.stats import lognorm
from scipy.stats import uniform
import numpy as np
import matplotlib.pyplot as plt

prior_fb = uniform(loc=0, scale=0.1)
post_fb = lognorm(s=np.log(1.15), scale=0.0076)

x = np.linspace(0, 0.1, 1000)
plt.plot(x, prior_fb.pdf(x), x, post_fb.pdf(x));
plt.legend(['prior', 'post'])