peak: Estimation of bi/multimodal distribution

Description Usage Arguments Value See Also Examples

Description

Estimating peak number of probabiliy density distribution

Usage

1
peak(pp)

Arguments

pp

The output of density function

Value

The value corresponding to each peak

See Also

genepeak, ModalFilter

Examples

 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)
  }

Fang0828/SCMarker documentation built on May 13, 2019, 12:51 p.m.