【问题标题】:How to make a plot of generalized beta distribution?如何绘制广义 beta 分布图?
【发布时间】:2013-05-24 22:45:39
【问题描述】:

我正在尝试使用 R(软件)通过以下方式绘制 beta-gumbel 分布, 流派的想法是,在 beta 分布的 pdf 中,我们不插入 x,而是使用 gumbel 的 cdf。但我找不到正确的情节。

x <- seq(-3, 3, length=100)
Fx = pgumbel(x,loc=0,scale=1)
y = dbeta(Fx,shape1=0.5,shape2=0.5)
plot(x, y, type="l", lty=2, xlab="x value", ylab="Density",ylim=c(0,1))

【问题讨论】:

  • 让我们知道您正在使用什么包。
  • 我没有安装任何外部包
  • pgumbel 来自哪里?
  • 它只是一个嵌入在 R 中的函数,用于计算 gumbel 的 cdf,请尝试使用 R 中的 ?pgumbel 获取帮助文件。
  • gumbelordinal 包中至少有 pgumbel 函数,您肯定必须下载并安装它们。

标签: r plot beta


【解决方案1】:

当你说你没有使用任何附加包时,我不相信你:pgumbel() 不在基础 R 中。library("sos"); findFn("pgumbel") 在很多地方都可以找到它,我使用了evd包。

这里有几个小问题。

library("evd")

主要是你想要length=100 而不是by=100(它给你一个单元素x 向量):

x <- seq(-3, 3, length=100)

实际计算没问题:

Fx = pgumbel(x,loc=0,scale=1)
y = dbeta(Fx,shape1=0.5,shape2=0.5)

您需要更改 ylim 才能看到发生了什么。但是,我也认为您需要做一些事情来解释差异 dx 以获得适当的密度函数(虽然这更像是 StackExchange 而不是 StackOverflow 问题)。

par(las=1,bty="l")  ## my personal preferences
plot(x, y, type="l", lty=2, xlab="x value", ylab="Density",ylim=c(0,40))

【讨论】:

  • 我试了几次,情节看起来不对...所以我只是输入了整个公式,它起作用了。
猜你喜欢
  • 2022-10-30
  • 2018-01-20
  • 1970-01-01
  • 1970-01-01
  • 2013-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多