轴上三维阵列的Gamma拟合

2024-04-19 20:26:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在阵列(3d)的轴0上计算gamma拟合。我试过下面的代码,但有点不对劲。你知道吗

import scipy.stats as st
import numpy as np
myarray = np.random.rand(20, 3, 3)
a, myloc, myscale = st.gamma.fit(myarray, axis=0)

Tags: 代码importnumpyasstatsnprandomscipy
2条回答

fit方法不接受axis参数。你知道吗

实际上,在scipy0.15.1(可能还有更老的版本)中,它确实“接受”了它,但忽略了它。这看起来像个虫子。当您给它提供任何它实际上没有使用的参数时,它应该引发一个TypeError,但它当前不是这样工作的:

In [20]: from scipy.stats import gamma

In [21]: gamma.fit([1,2,3,3,3,4,5,7])
Out[21]: (3.6899039741659925, 0.049374155400321737, 0.93515411814698823)

In [22]: gamma.fit([1,2,3,3,3,4,5,7], axis=123)
Out[22]: (3.6899039741659925, 0.049374155400321737, 0.93515411814698823)

In [23]: gamma.fit([1,2,3,3,3,4,5,7], flibbity=123)
Out[23]: (3.6899039741659925, 0.049374155400321737, 0.93515411814698823)

错误报告:https://github.com/scipy/scipy/issues/4932

它应该是scipy.stats,而不是scipy.stat。你知道吗

相关问题 更多 >