gpt4 book ai didi

python - python 中 qq-plot(或 probplot)的逐点置信度包络线

转载 作者:行者123 更新时间:2023-11-28 19:21:01 41 4
gpt4 key购买 nike

我有一个到达间隔时间列表,我正在使用 scipy.stats.probplot 绘制概率图(类似于 qq-plot)。我的数据在列表 l 中,我调用

scipy.stats.probplot(l, dist=stats.expon)

如何向图中添加逐点置信度包络线。以前的 SO answer展示了如何在 R 中执行此操作,但我需要在 python 中执行此操作。

我也尝试了 statsmodels,但它的功能似乎比等效的 scipy 略少(例如,它不计算 R^2 错误)。

最佳答案

我发布了一个稍微不同的例子,但它可能帮你...

#!/usr/bin/env python

from scipy.stats import t
from numpy import average, std
from math import sqrt

if __name__ == '__main__':
# data we want to evaluate: average height of 30 one year old male and
# female toddlers. Interestingly, at this age height is not bimodal yet
data = [63.5, 81.3, 88.9, 63.5, 76.2, 67.3, 66.0, 64.8, 74.9, 81.3, 76.2,
72.4, 76.2, 81.3, 71.1, 80.0, 73.7, 74.9, 76.2, 86.4, 73.7, 81.3,
68.6, 71.1, 83.8, 71.1, 68.6, 81.3, 73.7, 74.9]
mean = average(data)
# evaluate sample variance by setting delta degrees of freedom (ddof) to
# 1. The degree used in calculations is N - ddof
stddev = std(data, ddof=1)
# Get the endpoints of the range that contains 95% of the distribution
t_bounds = t.interval(0.95, len(data) - 1)
# sum mean to the confidence interval
ci = [mean + critval * stddev / sqrt(len(data)) for critval in t_bounds]
print "Mean: %f" % mean
print "Confidence Interval 95%%: %f, %f" % (ci[0], ci[1])

关于python - python 中 qq-plot(或 probplot)的逐点置信度包络线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25046966/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com