Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: empirical version of pnorm() and qnorm()?

Tags:

r

I have a normalization method that uses the normal distribution functions pnorm() and qnorm(). I want to alter my logic so that I can use empirical distributions instead of assuming normality. I've used ecdf() to calculate the empirical cumulative distributions but then realized I was beginning to write a function that basically was the p and q versions of the empirical. Is there a simpler way to do this? Maybe a package with pecdf() and qecdf()? I hate reinventing the wheel.

like image 733
JD Long Avatar asked Dec 17 '22 23:12

JD Long


1 Answers

You can use the quantile and ecdf functions to get qecdf and pecdf, respectively:

x <- rnorm(20)
quantile(x, 0.3, type=1) #30th percentile
Fx <- ecdf(x)
Fx(0.1)  # cdf at 0.1
like image 145
Aniko Avatar answered Jan 12 '23 21:01

Aniko