R与指数分布(2) 累积分布函数

累积分布函数,又叫累计分布函数,是概率密度函数的积分,能完整描述一个实随机变量X的概率分布。一般以大写“CDF”(Cumulative Distribution Function)表记。

对于所有实数x ,累积分布函数定义如下:



指数分布的累积分布函数可以写成:

R代码如下:
> set.seed(1000)
> x<-seq(-1,2,length.out=100)
> y<-pexp(x,0.5)
> plot(x,y,col="red",xlim=c(0,2),ylim=c(0,1),type='l',
+      xaxs="i", yaxs="i",ylab='density',xlab='',
+      main="The Exponential Cumulative Distribution Function")
> lines(x,pexp(x,1),col="green")
> lines(x,pexp(x,2),col="blue")
> lines(x,pexp(x,5),col="orange")
> legend("bottomright",legend=paste("rate=",c(.5, 1, 2,5)), lwd=1, col=c("red", "green","blue","orange"))


结果:


猜你喜欢

转载自jobar.iteye.com/blog/2153220