Skip to main content

Higher Order Spectral Analysis toolkit

Project description

Higher Order Spectral Analysis Toolkit

This package provides a comprehensive set of tools for higher-order spectral analysis in Python. It includes functions for estimating bicoherence, bispectrum, and various orders of cumulants.

Installation

You can install the HOSA toolkit using pip:

pip install higher-spectrum

Contents

Bicoherence

from spectrum import bicoherence, plot_bicoherence

bic, waxis = bicoherence(y, nfft=None, window=None, nsamp=None, overlap=None)
plot_bicoherence(bic, waxis)

bicoher

Cross Bicoherence

from spectrum import bicoherencex, plot_cross_bicoherence

bic, waxis = bicoherencex(w, x, y, nfft=None, window=None, nsamp=None, overlap=None)
plot_cross_bicoherence(bic, waxis)

bicoherx

Bispectrum Direct (using FFT)

from spectrum import bispectrumd, plot_bispectrum

Bspec, waxis = bispectrumd(y, nfft=None, window=None, nsamp=None, overlap=None)
plot_bispectrum(Bspec, waxis)

bispectr

Bispectrum Indirect

from spectrum import bispectrumi, plot_bispectrum_indirect

Bspec, waxis = bispectrumi(y, nlag=None, nsamp=None, overlap=None, flag='biased', nfft=None, wind='parzen')
plot_bispectrum_indirect(Bspec, waxis)

bispectri

Cross Bispectrum (Direct)

from spectrum import bispectrumdx, plot_cross_bispectrum

Bspec, waxis = bispectrumdx(x, y, z, nfft=None, window=None, nsamp=None, overlap=None)
plot_cross_bispectrum(Bspec, waxis)

bispectrdx

Cumulants (2nd, 3rd, and 4th order)

from spectrum import cumest, plot_cumulant

order = 2  # 2nd order
y_cum = cumest(y, norder=order, maxlag=20, nsamp=None, overlap=0, flag='biased', k1=0, k2=0)
plot_cumulant(np.arange(-20, 21), y_cum, order)

Cross-Cumulants (2nd, 3rd, and 4th order)

from spectrum import cum2x, cum3x, cum4x, plot_cross_covariance, plot_third_order_cross_cumulant, plot_fourth_order_cross_cumulant

# 2nd order cross-cumulant
ccov = cum2x(x, y, maxlag=20, nsamp=None, overlap=0, flag='biased')
plot_cross_covariance(np.arange(-20, 21), ccov)

# 3rd order cross-cumulant
c3 = cum3x(x, y, z, maxlag=20, nsamp=None, overlap=0, flag='biased', k1=0)
plot_third_order_cross_cumulant(np.arange(-20, 21), c3, k1=0)

# 4th order cross-cumulant
c4 = cum4x(w, x, y, z, maxlag=20, nsamp=None, overlap=0, flag='biased', k1=0, k2=0)
plot_fourth_order_cross_cumulant(np.arange(-20, 21), c4, k1=0, k2=0)

Features

  • Estimation of bicoherence and cross-bicoherence
  • Direct and indirect methods for bispectrum estimation
  • Cross-bispectrum estimation
  • Cumulant estimation up to 4th order
  • Cross-cumulant estimation up to 4th order
  • Plotting functions for all estimations

Requirements

  • Python 3.6+
  • NumPy
  • SciPy
  • Matplotlib

Contributing

Contributions to the HOSA toolkit are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

Acknowledgements

This toolkit is based on the Higher Order Spectral Analysis toolkit for MATLAB. We've adapted and extended it for Python users.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

higher_spectrum-0.2.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

higher_spectrum-0.2.0-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file higher_spectrum-0.2.0.tar.gz.

File metadata

  • Download URL: higher_spectrum-0.2.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.5

File hashes

Hashes for higher_spectrum-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f18174cfaf72a1159de1a4d7fb7f553c33afd26306eb3933336c3c06f3c2a3cc
MD5 ba1e65b8910bafd2d42c88568a3b0e0c
BLAKE2b-256 55517280545176addc9638c0e6db270bfbacd715e9803422a4e4251aa1154269

See more details on using hashes here.

File details

Details for the file higher_spectrum-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: higher_spectrum-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.5

File hashes

Hashes for higher_spectrum-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 585fc367c3e046ed0abac986721bf2c640bd22c784150be90d5e85c669065759
MD5 d07360ccba9ea74f36e7c17cb5e9a2aa
BLAKE2b-256 5f0f395d74df42925f1699c78dcc8a53204b15f170aa9fd967495250c35822df

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page