简体   繁体   English

置信区间图

[英]Confidence Interval Plot

I have two distributions of which I'd like to compare the 95% confidence interval of: 我想比较两个分布的95%置信区间:

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)

I can get the 95% confidence intervals, and mean of both distributions: 我可以获得95%的置信区间以及两种分布的均值:

prior_mean = prior_fb.mean()
prior_interval = prior_fb.interval(0.95)
post_mean = post_fb.mean()
post_interval = post_fb.interval(0.95)

I tried generating random variates and plotting those using the "interval plot" function of Origin, but I think Origin assumes a normal distribution for the data, so the "interval plot" does not really represent the 95% interval: 我尝试生成随机变量,并使用Origin的“间隔图”功能绘制那些变量,但我认为Origin假设数据为正态分布,因此“间隔图”并不真正代表95%的间隔:

使用随机变量的区间图

The interval for the prior should go from 0.0025 to 0.0975, as given by prior_fb.interval(0.95) . 先验的时间间隔应从0.0025到0.0975,由prior_fb.interval(0.95)

How can I plot and compare the intervals (and the mean) for the prior and the posterior using matplotlib? 如何使用matplotlib绘制和比较前后的间隔(和均值)?

I would use box plot from matplotlib, you can pass mean values instead of median and you can pass confidence interval: 我将使用来自matplotlib的箱形图,您可以传递平均值而不是中位数,并且可以传递置信区间:

from matplotlib import pyplot
fig, ax = pyplot.subplots()
ax.boxplot([prior_fb.rvs(size=1000),post_fb.rvs(size=1000)],conf_intervals=[prior_interval,post_interval],usermedians=[prior_mean,post_mean],labels=['Prior','Post'])

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM