Monday, 9 September 2013

Drawing Cumulative Distribution Function in r

Drawing Cumulative Distribution Function in r

I have the following pdf,
f(x)=2(1-x)^2; 2=>x>1
Now i have to plot the cdf of the random variable in r.
#cumulative distribution function
Fx <- function(x){
(2/3) * (x^3-3*x^2+3*x-1)
}
R <- runif(100,1,2)
cum_prob <- Fx(R) # determining cumulative probability
But i don't know which command should i use to draw the cdf .
hist() & barplot() are not appropriate for cdf. Because as far i know
plotting a cdf, it requires the values of random variable in X-axis, and
cumulative probability in Y-axis.
Also my variable is continuous.

No comments:

Post a Comment