Manoranjan Muthusamy
2013-Oct-31 12:25 UTC
[R] Extracting values from a ecdf (empirical cumulative distribution function) curve
Hi R users, I am a new user, still learning basics of R. Is there anyway to extract y (or x) value for a known x (or y) value from ecdf (empirical cumulative distribution function) curve? Thanks in advance. Mano. [[alternative HTML version deleted]]
Rui Barradas
2013-Oct-31 21:53 UTC
[R] Extracting values from a ecdf (empirical cumulative distribution function) curve
Hello, As for the problem of finding y given the ecdf and x, it's very easy, just use the ecdf: f <- ecdf(rnorm(100)) x <- rnorm(10) y <- f(x) If you want to get the x corresponding to given y, use linear interpolation. inv_ecdf <- function(f){ x <- environment(f)$x y <- environment(f)$y approxfun(y, x) } g <- inv_ecdf(f) g(0.5) Hope this helps, Rui Barradas Em 31-10-2013 12:25, Manoranjan Muthusamy escreveu:> Hi R users, > > I am a new user, still learning basics of R. Is there anyway to extract y > (or x) value for a known x (or y) value from ecdf (empirical cumulative > distribution function) curve? > > Thanks in advance. > Mano. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >