如何绘制广义β分布图? [英] How to make a plot of generalized beta distribution?

查看:104
本文介绍了如何绘制广义β分布图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to plot the beta-gumbel distribution using R(software) by the following, The genreal idea is that, in the pdf of beta distribution, instead of plugging in x, we use the cdf of gumbel instead. But I couldn't get the right plot.

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() is not在基础 R. library("sos");findFn("pgumbel") 各种地方都找到了,我用的是evd包.

I don't believe you when you say that you didn't use any add-on packages: pgumbel() is not in base R. library("sos"); findFn("pgumbel") finds it in a variety of places, I used the evd package.

这里有几个小问题.

library("evd")

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

The main thing is that you want length=100 rather than by=100 (which gives you a single-element x vector):

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 问题).

You need to change ylim to be able to see what's going on. However, I also think you need to do something to account for the differential dx in order to get a proper density function (that's more of a StackExchange than a StackOverflow question though).

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

这篇关于如何绘制广义β分布图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆