简体   繁体   English

绘制理论CDF

[英]plot the theoretical cdf

I am trying to plot the empirical cumulative distribution function and theoretical cumulative distribution function. 我正在尝试绘制经验累积分布函数和理论累积分布函数。 This is my R code: 这是我的R代码:

x=rgamma(40, 2, 1/3)
plot(ecdf(x))
lines(x, pgamma(x, shape = 2, scale = 3), type="l", col = "red")

But I got the graph in the attached file which I think it is not reasonable. 但是我在附件中找到了该图,我认为这是不合理的。 What I do wrong? 我做错了什么? 在此处输入图片说明

Expanding on my comment... is this what you are looking for? 扩展我的评论...这是您要找的吗?

x=rgamma(40, 2, 1/3)
plot(ecdf(x))
curve(pgamma(x, shape = 2, scale = 3), 
      0, 30, 
      add=TRUE,
      col="red")

This results in the following plot: 结果如下图:

在此处输入图片说明

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

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