python - 子类化 scipy.stats.rv_continuous
问题描述
我花了相当大的努力和搜索尝试子类scipy.stats.rv_continuous
化以生成 Weibull 概率分布的新参数化 ( weibull_max
),但不明白应该如何完成。我正在尝试将分布设置为能够使用 pdf、cdf、随机变量和拟合方法。
我可以使用以下独立函数生成所需的 pdf:
def weibull3P_pdf(x, shape, thres=0, loc=0, scale=1):
return np.flip(scistats.weibull_max
.pdf(-x - thres, shape,
loc=loc, scale=scale))
有人会猜测以下应该可以工作:
class weibull3P_gen(scistats.rv_continuous):
def _argcheck(self, c, k):
return (c > 0) & (k < 0)
def _get_support(self, c, k):
return k, -k
def _pdf(self, x, c, k):
# Adjusted accordingly from weibull_max._pdf
return c * pow(-x - k, c - 1) * np.exp(-pow(-x - k, c))
weibull3P = weibull3P_gen(name="weibull3P")
但该pdf
方法不会产生相同的结果。欢迎任何指点。
解决方案
推荐阅读
- javascript - 为什么在将图像加载到画布时使用 style.display = 'none'
- azure - 我无法在 Azure 容器注册表中选择图像
- javascript - mongoose mongodb - 删除所有条件为真的地方,除了一个
- c - Wno-pointer-arith 标志在不同 gcc 版本之间的处理方式不同
- excel - 如何防止用户在 Google 表格中使用 Excel 电子表格
- reactjs - 如何设置抽屉组件中未显示的初始屏幕?
- matlab - 在 MATLAB 中索引一个更大的向量
- symfony - JMSSerializer 事件不适用于具体类型
- load-balancing - 如何使用重定向配置 Wildfly 负载平衡
- java - Android Studio:找不到方法