美好的一天!我有两个伽玛分布,并希望找到它们的差异分布。使用np.random.gamma
通过参数生成分布,但结果分布不时有很大差异。码:
import numpy as np
from scipy.stats import gamma
for i in range(0, 10):
s1 = np.random.gamma(1.242619972, 0.062172619, 2000) + 0.479719122
s2 = np.random.gamma(456.1387112, 0.002811328, 2000) - 0.586076723
r_a, r_loc, r_scale = gamma.fit(s1 - s2)
print(1 - gamma.cdf(0.0, r_a, r_loc, r_scale))
结果:
0.4795655021157602
0.07061938039031612
0.06960741675590854
0.4957568913729331
0.4889900326940878
0.07381963810128422
0.0690800784280835
0.07198551429809896
0.07659274505827551
0.06967441935502583
我收到两个完全不同的cdf 0:0.48和0.07。可能是什么问题?
您将伽马分布拟合到两个其他伽玛分布之间的差异。伽马分布只能是正数,所以没有意义,你不能期望得到一致的答案。如果您打印平均差异,您将获得一致的结果。