如何添加接近3的泊松分布曲线?

问题描述 投票:-2回答:1

我想在现有的情节中添加曲线。该曲线应该是接近平均值3的泊松分布曲线。

我试过这个代码点是一个1000值的向量

plot(c(1:1000), points,type="l")
abline(h=3)
x = 0:1000
curve(dnorm(x, 3, sqrt(3)), lwd=2, col="red", add=TRUE)

我得到了一个情节,但没有任何曲线。我希望看到接近3的曲线。

r plot poisson
1个回答
0
投票

你可以这样做:

plot(0:20, 3+dpois( x=0:20, lambda=3 ), xlim=c(-2,20))
normden <- function(x){3+dnorm(x, mean=3, sd=sqrt(3))}
curve(normden, from=-4, to=20, add=TRUE, col="red")

运行此代码将产生以下内容:

那是你的意图吗?

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.