An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20131101/f13a8f0d/attachment.pl>
Extracting values from a ecdf (empirical cumulative distribution function) curve
6 messages · William Dunlap, Duncan Mackay, Manoranjan Muthusamy
it gives 'NA' (for whatever y value).
What 'y' values were you using? inf_f maps probabilities (in [0,1]) to values in the range of the orginal data, x, but it will have problems for a probability below 1/length(x) because the original data didn't tell you anything about the ecdf in that region. > X <- c(101, 103, 107, 111) > f <- ecdf(X) > inv_f <- inv_ecdf(f) > inv_f(seq(0, 1, by=1/8)) [1] NA NA 101 102 103 105 107 109 111 Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Manoranjan Muthusamy Sent: Thursday, October 31, 2013 6:18 PM To: Rui Barradas Cc: r-help at r-project.org Subject: Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve Thank you, Barradas. It works when finding y, but when I tried to find x using interpolation for a known y it gives 'NA' (for whatever y value). I couldn't find out the reason. Any help is really appreciated. Thanks, Mano On Thu, Oct 31, 2013 at 10:53 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
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-
PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html <http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
[[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.
Hi There is a print method for ecdf So print(f) should give you an idea of what is going on See ?ecdf HTH Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mackay at northnet.com.au -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Manoranjan Muthusamy Sent: Friday, 1 November 2013 11:18 To: Rui Barradas Cc: r-help at r-project.org Subject: Re: [R] Extracting values from a ecdf (empirical cumulative distribution function) curve Thank you, Barradas. It works when finding y, but when I tried to find x using interpolation for a known y it gives 'NA' (for whatever y value). I couldn't find out the reason. Any help is really appreciated. Thanks, Mano
On Thu, Oct 31, 2013 at 10:53 PM, Rui Barradas <ruipbarradas at sapo.pt> wrote:
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<https://stat.ethz.ch/m ailman/listinfo/r-help> PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html <http://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
______________________________________________ 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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20131101/71b8591e/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20131101/40e1ff30/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20131101/26a270dc/attachment.pl>