是否可以使用scipy.stats创建自定义的2d概率密度函数?

时间:2019-12-18 12:48:44

标签: python scipy

我想使用python(例如,伽玛-vonmises分布)制作自定义2d概率密度函数(pdf)。
使用scipy.stats制作自定义1d pdf效果很好。

class 1d_pdf(stats.rv_continuous):
# a, b, c is the hyper-parameters of this distribution
    def _pdf(self, x, a, b, c):
        return mypdf 
    def _argcheck(self, a, b, c): 
        return argcheck
1d_pdf = 1d_pdf(name="1d_pdf")

pdf = 1d_pdf(a=1, b=1, c=1) # no error

但是,自定义2d pdf会引发错误。

# a, b, c is the hyper-parameters of this distribution
class 2d_pdf(stats.rv_continuous):
    def _pdf(self, x, y, a, b, c):
        return mypdf 
    def _argcheck(self, a, b, c): 
        return argcheck
2d_pdf = 2d_pdf(name="2d_pdf")

pdf = 2d_pdf(a=1, b=1, c=1)

返回

_parse_args() missing 1 required positional argument: 'y'

也许y被识别为超参数。
我该如何避免这个问题?

谢谢。

0 个答案:

没有答案