spectral_connectivity.statistics.power_confidence_intervals#

power_confidence_intervals(n_tapers: int, power: ndarray[tuple[int, ...], dtype[floating]] | float = 1, ci: float = 0.95) tuple[ndarray[tuple[int, ...], dtype[floating]], ndarray[tuple[int, ...], dtype[floating]]][source]#

Compute confidence intervals for multitaper power spectrum estimates.

Uses chi-squared distribution to compute confidence bounds for power spectral density estimates from multitaper analysis.

Parameters:
  • n_tapers (int) – Number of tapers used in multitaper estimation.

  • power (NDArray[floating] or float, default=1) – Power spectrum estimates. Can be array of values or scalar.

  • ci (float, default=0.95) – Confidence level, must be in range [0.5, 1.0].

Returns:

  • lower_bound (NDArray[floating]) – Lower confidence bounds for power estimates.

  • upper_bound (NDArray[floating]) – Upper confidence bounds for power estimates.

Examples

>>> import numpy as np
>>> # Single power estimate with 5 tapers
>>> lower, upper = power_confidence_intervals(n_tapers=5, power=1.0, ci=0.95)
>>> print(f"95% CI: [{lower:.3f}, {upper:.3f}]")
>>>
>>> # Multiple power estimates
>>> power_vals = np.array([0.5, 1.0, 2.0, 5.0])
>>> lower, upper = power_confidence_intervals(5, power_vals, 0.95)

References

[1]

Kramer, M.A., and Eden, U.T. (2016). Case studies in neural data analysis: a guide for the practicing neuroscientist (MIT Press).