specprop: Spectral properties

specpropR Documentation

Spectral properties

Description

This function returns a list of statistical properties of a frequency spectrum.

Usage

specprop(spec, f=NULL,
str = FALSE, flim=NULL, mel=FALSE,
plot = FALSE, type = "l", xlab=NULL, ylab = NULL,
col.mode = 2, col.quartiles = 4, ...)

Arguments

spec

a data set resulting of a spectral analysis obtained with spec or meanspec (not in dB).

f

sampling frequency of spec (in Hz).

str

logical, if TRUE returns the results in a structured table.

flim

a vector of length 2 to specifgy the frequency limits of the analysis (in kHz)

mel

a logical, if TRUE the (htk-)mel scale is used.

plot

if 1 returns the spectrum , if 2 returns the cumulative spectrum, both of them with the first quartile, the third quartile, the median and the mode plotted (by default FALSE).

type

if plot is TRUE, type of plot that should be drawn. See plot for details (by default "l" for lines).

xlab

label of the x axis.

ylab

label of the y axis.

col.mode

colour of the mode segments (by default blue).

col.quartiles

colour of the quartiles segments (by default red).

...

other arguments to be passed to plot

Details

The spectrum is converted in a probability mass function (PMF).
If a selected value has to be selected with $, the argument str has to be set to FALSE.

Value

A list of 15 values is returned

mean

mean frequency (see mean)

sd

standard deviation of the mean (see sd)

sem

standard error of the mean

median

median frequency (see median)

mode

mode frequency, i.e. the dominant frequency

Q25

first quartile (see quantile)

Q75

third quartile (see quantile)

IQR

interquartile range (see IQR)

cent

centroid, see note

skewness

skewness, a measure of asymmetry, see note

kurtosis

kurtosis, a measure of peakedness, see note

sfm

spectral flatness measure (see sfm)

sh

spectral entropy (see sh)

prec

frequency precision of the spectrum

Note

Centroid is computed according to:

C = \sum_{i = 1}^{N} x_i\times{y_i}


with:
x = frequencies, y = relative amplitude of the i frequency,
N = number of frequencies.

Skewness is computed according to:

S = \frac{\sum_{i = 1}^{N}(x_i-\bar{x})^{3}}{N-1}\times{\frac{1}{\sigma^{3}}}

.
S < 0 when the spectrum is skewed to left,
S = 0 when the spectrum is symetric,
S > 0 when the spectrum is skewed to right.
Spectrum asymmetry increases with |S|.

Kurtosis is computed according to:

K = \frac{\sum_{i = 1}^{N}(x_i-\bar{x})^{4}}{N-1}\times{\frac{1}{\sigma^{4}}}

.
K < 3 when the spectrum is platikurtic, i.e. it has fewer items at the center and at the tails than the normal curve but has more items in the shoulders,
K = 3 when the spectrum shows a normal shape,
K > 3 when the spectrum is leptokurtic, i.e. it has more items near the center and at the tails, with fewer items in the shoulders relative to normal distribution with the same mean and variance.

Author(s)

Jerome Sueur and Caroline Simonis, and a patch by Jesse Ross (Dec. 2012)

Examples

data(orni)
a<-meanspec(orni,f=22050,plot=FALSE)
specprop(a,f=22050)
# to get a single measure of the list
specprop(a,f=22050)$mode
# to get the results structured
specprop(a,f=22050,str=TRUE)
# to limit the analysis between 4 and 6 kHz
specprop(a,f=22050,flim=c(4,6),str=TRUE)
# plots
specprop(a,f=22050,plot=1)
specprop(a,f=22050,plot=2)
# (htk-)mel scale
require(tuneR)
mel <- melfcc(orni, nbands = 256, dcttype = "t3", fbtype = "htkmel", spec_out=TRUE)
melspec.mean <- apply(mel$aspectrum, MARGIN=2, FUN=mean)
specprop(melspec.mean, f=22050, mel=TRUE)
# be aware that flim is always given in kHz even if mel=TRUE
specprop(melspec.mean, f=22050, flim=c(4,6), mel=TRUE, plot=TRUE)

seewave documentation built on Oct. 19, 2023, 5:07 p.m.

Related to specprop in seewave...