Reputation: 849
Give a discrete distribution X = [2,1,5]
with weight W = [0.5,0.2,0.3]
.How to plot cdf of this distribution in r?
Upvotes: 0
Views: 424
Reputation: 101189
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)
Upvotes: 0