fwhm {gsignal}R Documentation

Full width at half maximum

Description

Compute peak full-width at half maximum or at another level of peak maximum for a vector or matrix.

Usage

fwhm(
  x = seq_len(length(y)),
  y,
  ref = c("max", "zero", "middle", "min", "absolute"),
  level = 0.5
)

Arguments

x

samples at which y is measured, specified as a vector. I.e., y is sampled as y[x]. Default: seq_len(length(y)).

y

signal to find the width of. If y is a matrix, widths of all columns are computed.

ref

reference. Compute the width with reference to:

"max" | "zero"

max(y)

"middle" | "min"

min(y) + max(y)

"absolute"

an absolute level of y

level

the level at which to compute the width. Default: 0.5.

Value

Full width at half maximum, returned as a vector with a length equal to the number of columns in y, or 1 in case of a vector.

Author(s)

Petr Mikulik.
Conversion to R by Geert van Boxtel, G.J.M.vanBoxtel@gmail.com.

Examples

x <- seq(-pi, pi, 0.001)
y <- cos(x)
w <- fwhm(x, y)
m <- x[which.max(y)]
f <- m - w/2
t <- m + w/2
plot(x, y, type="l",
     panel.first = {
       usr <- par('usr')
       rect(f, usr[3], t, usr[4], col = rgb(0, 1, 0, 0.4), border = NA)
     })
abline(h = max(y) / 2, lty = 2, col = "gray")


[Package gsignal version 0.3-5 Index]