我正在开展一个项目,该项目涉及组合两个威布尔分布,从而创建一个双峰曲线。然后,我的目标是使用它做出预测。我在网上搜索过,我似乎无法在此找到任何内容,或者R是否有一个允许我组合两个Weibull的函数。 下面显示了我用来创建两个Weibull分布的代码,我希望将它们合并为一个单概率密度函数。
curve(dweibull(x, scale=30.59898985, shape=2.27136646),from=0, to=70, main="Weibull distribution")
curve(dweibull(x, scale=19.39743639, shape=1.22800332),from=0, to=70, main="Weibull distribution")
任何帮助都会很棒。
谢谢!
答案 0 :(得分:3)
合并概率分布然后使用最终列表中的元素“y”进行预测是否合理?如果是这样,这应该工作。最终的AUC仍然是~1。
dwb1 <- curve(dweibull(x, scale=30.59898985, shape=2.27136646),from=0, to=70, main="Weibull distribution")
dwb2 <- curve(dweibull(x, scale=19.39743639, shape=1.22800332),from=0, to=70, main="Weibull distribution")
# combine
final.dwb <- lapply(c("x", "y"), (function(i){
(dwb1[[i]] + dwb2[[i]])/2
}))
names(final.dwb) <- c("x", "y")
# plot
plot(final.dwb$y ~ final.dwb$x, xlim=c(0,70), main = "combined Weibull distributions", type = "n", las = 2)
lines(final.dwb$y ~ final.dwb$x, xlim=c(0,70), main = "combined Weibull distributions")
假设您想要感兴趣的概率
t1 = 30
在你拥有的x中搜索并找到最接近t1然后返回相应的y
id <- which.min(abs(t1 - final.dwb$x))
final.dwb$y[id]