Learn R Programming

soundgen (version 2.9.0)

getSurprisal_matrix: Get surprisal per matrix

Description

Internal soundgen function called by getSurprisal.

Usage

getSurprisal_matrix(
  x,
  win,
  method = c("acf", "np")[1],
  sameLagAllFreqs = TRUE,
  weightByAmpl = TRUE,
  weightByPrecision = TRUE,
  onlyPeakAutocor = FALSE,
  rescale = FALSE
)

Arguments

x

input matrix such as a spectrogram (columns = time, rows = frequency)

win

length of analysis window

method

(for $surprisal only, has no effect on $info and $kl) acf = change in maximum autocorrelation after adding the final point; np = nonlinear prediction (see nonlinPred - works but is VERY slow); none = do not calculate $surprisal to save time and only return $info and $kl

sameLagAllFreqs

(only for method = 'acf') if TRUE, the bestLag is calculated by averaging the ACFs of all channels, and the same bestLag is used to calculate the surprisal in each frequency channel (we expect the same "rhythm" for all frequencies); if FALSE, the bestLag is calculated separately for each frequency channel (we can track different "rhythms" at different frequencies)

weightByAmpl

if TRUE, ACFs and surprisal are weighted by max amplitude per frequency channel

weightByPrecision

if TRUE, surprisal is weighted by the current autocorrelation, so deviations from a previous pattern are more surprising if this pattern is strong

onlyPeakAutocor

if TRUE, only peaks of ACFs are considered (so bestLag can never be 1, and the first change after a string of static values results in surprisal = NA)

rescale

if TRUE, surprisal is normalized from (-Inf, Inf) to [-1, 1]