概率分布值图

发布于 2024-12-07 19:52:03 字数 266 浏览 0 评论 0原文

我有

求和为 1

概率值: 0.06,0.06,0.1,0.08,0.12,0.16,0.14,0.14,0.08,0.02,0.04 ,将随机变量可能取其值的相应区间 上面列表中的相应概率:

126,162,233,304,375,446,517,588,659,730,801,839

如何绘制概率分布?

在x轴上,间隔值,间隔直方图与概率值之间?

谢谢。

I have

probability values: 0.06,0.06,0.1,0.08,0.12,0.16,0.14,0.14,0.08,0.02,0.04 ,summing up to 1

the corresponding intervals where a stochastic variable may take its value with the corresponding probability from the above list:

126,162,233,304,375,446,517,588,659,730,801,839

How can I plot the probability distribution?

On the x axis, the interval values, between the intervals histogram with the probability value?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

写下不归期 2024-12-14 19:52:03

怎么样

x <- c(126,162,233,304,375,446,517,588,659,730,801,839)
p <- c(0.06,0.06,0.1,0.08,0.12,0.16,0.14,0.14,0.08,0.02,0.04)
plot(x,c(p,0),type="s")
lines(x,c(0,p),type="S")
rect(x[-1],0,x[-length(x)],p,col="lightblue")

快速回答 ? (包含 rect 后,您可能不需要 lines 调用,并且可以将其更改为 plot(x,p,type="n")<像往常一样,我会推荐 par(bty="l",lty=1) 作为我首选的图形默认值...)

(说明:“s”和“S”是两个不同的阶梯类型(请参阅 ?plot 中的详细信息): I使用它们来获得分布的左边界和右边界。)

编辑:在您的评论中,您说“(它)看起来不像直方图”。不太清楚你想要什么。我在上面的例子中添加了矩形——也许就这样了?或者你也可以这样做,

b <- barplot(p,width=diff(x),space=0)

但是正确设置 x 轴标签是一件很痛苦的事情。

How about

x <- c(126,162,233,304,375,446,517,588,659,730,801,839)
p <- c(0.06,0.06,0.1,0.08,0.12,0.16,0.14,0.14,0.08,0.02,0.04)
plot(x,c(p,0),type="s")
lines(x,c(0,p),type="S")
rect(x[-1],0,x[-length(x)],p,col="lightblue")

for a quick answer? (With the rect included you might not need the lines call and might be able to change it to plot(x,p,type="n"). As usual I would recommend par(bty="l",lty=1) for my preferred graphical defaults ...)

(Explanation: "s" and "S" are two different stair-step types (see Details in ?plot): I used them both to get both the left and right boundaries of the distribution.)

edit: In your comments you say "(it) doesn't look like a histogram". It's not quite clear what you want. I added rectangles in the example above -- maybe that does it? Or you could do

b <- barplot(p,width=diff(x),space=0)

but getting the x-axis labels right is a pain.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文