Learn R Programming

YEAB (version 1.0.6)

fwhm: Full Width at Half Maximum

Description

Full Width at Half Maximum

Usage

fwhm(x, y)

Value

a list with the fwhm and the x at which the max ocurred

Arguments

x

numeric, a vector of values from a distribution (density)

y

numeric, a vector of probabilities

Details

The function allows to compute the spread of a symmetric function even when it is not normally distributed. It first finds the x at which y is max, then x1 and x2 can be recovered using x1=peak-fwhm/2, x2=peak+fwhm/2

Examples

Run this code
set.seed(170)
rx <- rnorm(100)
den <- density(rx)
fval <- fwhm(den$x, den$y)
x1 <- fval$peak - fval$fwhm / 2
x2 <- fval$peak + fval$fwhm / 2
plot(den)
abline(v = c(x1, fval$peak, x2), col = c(1, 2, 1))

Run the code above in your browser using DataLab