calc_PSD: Power Spectral Density Calculator

View source: R/calc_functions.R

calc_PSDR Documentation

Power Spectral Density Calculator

Description

This function estimates the log power spectral density against the log frequency, and calculates a slope \alpha.

Usage

calc_PSD(chain, max_freq = 0.1, filter_freq = TRUE, plot = FALSE)

Arguments

chain

Matrix of n x d dimensions, n = iterations, d = dimensions sequence

max_freq

The maximum frequency to be considered in PSD if filter_freq = TRUE. See also Details.

filter_freq

Boolean. Whether PSD only considers the frequencies between 0 and max_freq. The default setting is TRUE. See also Details.

plot

Boolean. Whether to return a plot or the elements used to make it.

Details

A number of studies have reported that cognitive activities contain a long-range slowly decaying autocorrelation. In the frequency domain, this is expressed as S(f) ~ 1/f^{-\alpha}, with f being frequency, S(f) being spectral power, and \alpha \epsilon [0.5,1.5] is considered 1/f scaling. See See \insertCitezhu2018MentalSamplingMultimodal;textualsamplr for a comparison of Levy Flight and PSD measures for different samplers in multimodal representations.

The default frequency range in PSD analysis extends from 0 to 0.1, which is specified by max_freq. It is because the logarithmic spectral power density tends to flatten beyond a frequency of 0.1. As a result, some researchers (e.g., \insertCitegildenNoiseHuman1995;nobracketssamplr; \insertCitezhu2022UnderstandingStructureCognitive;nobracketssamplr) estimate the value of \alpha using only frequencies below 0.1. When filter_freq is set to FALSE, the frequency range will be from 0 to the Nyquist frequency.

Value

Returns a list with log frequencies, log PSDs, and slope and intercept estimates.

References

\insertAllCited

Examples

set.seed(1)
chain1 <- sampler_mh(1, "norm", c(0,1), diag(1))
calc_PSD(chain1[[1]], plot= TRUE)

samplr documentation built on April 4, 2025, 12:30 a.m.