Finding percentile of a value from an empirical distribution
Hello, I am not sure how to do this in R. Any suggestion would be appreciated. I have a vector of values from where I build an empirical CDF. For example:
x <- seq(1,100) x <- sample(x,1000,replace=T) quantile(x,probs=seq(0,1,.05))
0% 5% 10% 15% 20% 25% 30% 35% 40% 45% 50% 55% 1.00 5.00 10.00 16.00 20.00 25.00 31.00 36.00 41.00 45.55 50.00 56.00 60% 65% 70% 75% 80% 85% 90% 95% 100% 60.00 65.00 70.00 74.00 80.00 85.00 91.00 95.05 100.00 I would like to write a function that takes in a number z and vector x (i.e. the raw vector).It returns percentile of z wrt x. E.g.
f(71,x)
Should return something around 0.708 or 0.709. I am wondering if there is any pre-packaged functions that do this in R? If not, how can I write such a function. Any suggestion would be appreciated. Robert