简体   繁体   English

如何将plot理论帕累托分布在R?

[英]How to plot theoretical Pareto distribution in R?

I need to plot theoretical Pareto distribution in R.我需要 R 中的 plot 理论帕累托分布。

I want this as a line - not points and not polylines.我希望这是一条线——不是点也不是多段线。

My distribution function is 1−(1/x)^2.我的分布 function 是 1−(1/x)^2。

I plotted empirical distribution of my sample and also theoretical distribution at one graph:我在一张图中绘制了样本的经验分布和理论分布:

ecdf(b2)
plot(ecdf(b2))
lines(x, (1-(1/x)^2), col = "red", lwd = 2, xlab = "", ylab = "")

But I got:但我得到了:

在此处输入图像描述

You can see that red line is not continuous, it's something like polyline.你可以看到红线不是连续的,它有点像折线。 Is it possible to get the continuous red line?有没有可能得到连续的红线?

Do you have any advices?你有什么建议吗?

Use curve() instead.请改用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)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM