Re: [R] How to find maximum values on the density function of a random variable

2009-03-12 Thread Mike Lawrence
rv <- rbinom(1,1,0.1) + rnorm(1) d.rv = density(rv) d.x = d.rv$x d.y = d.rv$y d.rv.max = d.rv$x[which.max(d.rv$y)] plot(d.rv) abline(v=d.rv.max) #that what you want? On Thu, Mar 12, 2009 at 6:28 PM, wrote: > I would like to find the maximum values on the density function of a > rando

[R] How to find maximum values on the density function of a random variable

2009-03-12 Thread guox
I would like to find the maximum values on the density function of a random variable. For example, I have a random variable rv <- rbinom(1,1,0.1) + rnorm(1) Its density function is given by density(rv) and can be displayed by plot(density(rv)). How to calculate its maximum values? A densi