【问题标题】:four parameter beta distribution in RR中的四参数β分布
【发布时间】:2018-08-31 04:12:42
【问题描述】:

是否有一个内置函数来计算 R 中的四参数 beta 分布?即,具有两个形状参数和两个边界参数的分布,因此它不是有界的 [0,1]?

我自己做了,但很好奇这个功能是否已经存在。无需重新发明轮子。

shp1 <- 20
shp2 <- 5
X <- seq(0,1,length.out = 100)
Y <- dbeta(x = X,shape1 = shp1, shape2 = shp2)
plot(X,Y)
# scaled between two boundaries
dbeta4param <- function(x,shp1,shp2,bnd1,bnd2){
  mask = (x>=bnd1 & x<=bnd2)
  xScale = (x-bnd1)/(bnd2-bnd1)
  mask * dbeta(xScale,shape1=shp1,shape2=shp2)/(bnd2-bnd1)
}
bnd1 <- 2
bnd2 <- 4
X2 <- seq(bnd1,bnd2,length.out = 100)
Y2 <- dbeta4param(x=X2, shp1 = shp1, shp2 = shp2, bnd1 = bnd1, bnd2 = bnd2)
plot(X2,Y2)

【问题讨论】:

标签: r beta-distribution


【解决方案1】:

CRAN Task View: Probability Distributions 始终是关于在哪里可以找到各种R 概率分布的好资源。根据它,您应该使用extraDistr 包(例如extraDistr::rnsbeta)。

【讨论】:

  • 确实如此。正如@Onyambu 评论的那样,我正在寻找概括。我调用了特殊函数 beta() 来创建自己的函数:dbeta4param &lt;- function(x,shp1,shp2,bnd1,bnd2){ ((x-bnd1)^(shp1-1) * (bnd2 - x)^(shp2-1)) / ((bnd2 - bnd1)^(shp1+shp2-1) * beta(shp1,shp2)) }。确实extraDistr::rnsbeta 看起来非常相似,并且可以满足我的需求。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-13
  • 2020-03-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-14
相关资源
最近更新 更多