如何在 R 中绘制理论帕累托分布?
How to plot theoretical Pareto distribution in R?
我需要在 R 中绘制理论帕累托分布。
我希望这是一条线 - 不是点也不是折线。
我的分布函数是1−(1/x)^2.
我在一张图中绘制了样本的经验分布和理论分布:
ecdf(b2)
plot(ecdf(b2))
lines(x, (1-(1/x)^2), col = "red", lwd = 2, xlab = "", ylab = "")
但是我得到了:
可以看到红线不是连续的,有点像折线。是否可以得到连续的红线?
你有什么建议吗?
改用curve()
。
library(EnvStats)
set.seed(8675309)
# You did not supply the contents of b2 so I generated some
b2 <- rpareto(100, 1, 2)
plot(ecdf(b2))
ppareto <- function(x) 1−(1/x)^2
curve(ppareto, col = "red", add = TRUE)
我需要在 R 中绘制理论帕累托分布。
我希望这是一条线 - 不是点也不是折线。
我的分布函数是1−(1/x)^2.
我在一张图中绘制了样本的经验分布和理论分布:
ecdf(b2)
plot(ecdf(b2))
lines(x, (1-(1/x)^2), col = "red", lwd = 2, xlab = "", ylab = "")
但是我得到了:
可以看到红线不是连续的,有点像折线。是否可以得到连续的红线?
你有什么建议吗?
改用curve()
。
library(EnvStats)
set.seed(8675309)
# You did not supply the contents of b2 so I generated some
b2 <- rpareto(100, 1, 2)
plot(ecdf(b2))
ppareto <- function(x) 1−(1/x)^2
curve(ppareto, col = "red", add = TRUE)