ValueError:scipy rv_continuous参数中的域错误

2024-10-01 07:29:07 发布

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

我试图抽样随机变量受给定的概率密度函数(pdf)与scipy.stats.rv_连续公司名称:

class Distribution(stats.rv_continuous):
    def _pdf(self,x, _a, _c):
        return first_hitting_time(x, _a, _c)

其中函数第一次击中时间

^{pr2}$

然后我继续

myrv= Distribution(name='hittingtime', a=0.002,b=30.0)
data3= myrv.rvs(size=10000, _a=1.0, _c=0.0)

翻译开始抱怨-

Traceback (most recent call last):

  File "<ipython-input-246-71f67047462b>", line 1, in <module>
    data3= myrv.rvs(size=10000, _a=1.0, _c=0.0)

  File "C:\Users\ME\AppData\Local\Continuum\Anaconda2\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 856, in rvs
    raise ValueError("Domain error in arguments.")

ValueError: Domain error in arguments.

似乎如果我将_c设置为大于0.0的某个数字,它可以正常工作,但对于小于0的_c则不行。在

我对此有点困惑。任何帮助都将不胜感激。在


Tags: insizepdfdomainstatslineerrorscipy
1条回答
网友
1楼 · 发布于 2024-10-01 07:29:07

来自the documentation

Subclassing

New random variables can be defined by subclassing the rv_continuous class and re-defining at least the _pdf or the _cdf method (normalized to location 0 and scale 1).

If positive argument checking is not correct for your RV then you will also need to re-define the _argcheck method.

从你的函数中我不清楚_a和{}代表什么,但看起来你希望它们是负的。在

请参阅默认实现in the source of ^{}

相关问题 更多 >