Spaceship222
Spaceship222

Reputation: 849

Given a discrete distribution,how to plot cdf?

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

Answers (1)

ThomasIsCoding
ThomasIsCoding

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

Related Questions