Re: [R] How to identify the two largest peaks in a trimodal distribution

2007-10-13 Thread jim holtman
You can use 'rle' to find where the direction changes and use that to determine the peaks: > # create test data > x <- seq(-2,7, length=2000) > y <- dnorm(x) + dnorm(x,3) > plot(y,type='l') > # find where direction changes from plus to minus > z <- rle(diff(y) > 0)# find where breaks are > z R

Re: [R] How to identify the two largest peaks in a trimodal distribution

2007-10-13 Thread Paul Smith
On 10/13/07, Rob Knell <[EMAIL PROTECTED]> wrote: > I'm trying to do a simulation that involves identifying the minimum > point between two peaks of a (usually) bimodal distribution. I can do > this easily if there are only two peaks: > > CnBdens<-density(Ys/Xs) #probability density function for ra

[R] How to identify the two largest peaks in a trimodal distribution

2007-10-12 Thread Rob Knell
Hello all I'm trying to do a simulation that involves identifying the minimum point between two peaks of a (usually) bimodal distribution. I can do this easily if there are only two peaks: CnBdens<-density(Ys/Xs) #probability density function for ratio of Ys to Xs for(p in