简体   繁体   中英

Given a discrete distribution,how to plot cdf?

给出一个离散分布X = [2,1,5] ,权重W = [0.5,0.2,0.3]如何在 r 中绘制该分布的 cdf?

Maybe this is what you want:

xx <- sort(x)
WW <- cumsum(W[order(x)])
plot(xx,WW,type="s",col = 2, xlab = "x",ylab = "p(x)")
points(xx,WW,col = 4)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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