Description Usage Arguments Value See Also Examples
Estimating peak number of probabiliy density distribution
1 | peak(pp)
|
pp |
The output of density function |
The value corresponding to each peak
genepeak, ModalFilter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | x=c(rnorm(50,4,0.5),rep(0,length=20))
pp=density(x)
peak(pp)
## The function is currently defined as
function (pp)
{
y = pp$y
x = pp$x
Hpeak = c()
for (i in 2:(length(y) - 1)) {
if (y[i] >= y[i - 1] & y[i] > y[i + 1]) {
Hpeak = rbind(Hpeak, c(x[i], y[i]))
}
}
if (length(Hpeak) == 0) {
Hpeak = rbind(Hpeak, c(0, 0))
}
Hpeak = as.data.frame(Hpeak)
names(Hpeak) = c("H", "Density")
return(Hpeak)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.