[R] How to calculate the distance between two density functions
dwinsemius at comcast.net
Fri Dec 5 18:13:52 CET 2008
A similar question was posed and answered:
Two aspects needed to be addressed ... specifying the same domain, and
getting the x-values to "line up" prior to the subtraction (or
whatever function is desired).
What are you going to do when the two functions cross?
d1 <- dnorm(seq(-2,2,by=.1))
d2 <- dnorm(seq(-2,2,by=.1), mean=2)
d4 <- dnorm(seq(-4,4,by=.1))
d5 <- dnorm(seq(-4,4,by=.1), sd=5)
On Dec 5, 2008, at 8:59 AM, Chang Jia-Ming wrote:
> Dear all,
> I wrote the following code to calculate the density functions for
> two data
> sets, respectively.
> den_str <-density(str_data$Similarity);
> den_non_str <-density(nonstr_data$Similarity);
> However, I would like to knowing the difference between den_str and
> den_non_str, that is, the difference between the region under the
> curve of
> the den_str and the region under the curve of the den_non_str.
> How to do?
> Thank you for help.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help