`import "github.com/mjibson/go-dsp/spectral"`

Package spectral provides spectral analysis functions for digital signal processing.

- func Pwelch(x []float64, Fs float64, o *PwelchOptions) (Pxx, freqs []float64)
- func Segment(x []float64, size, noverlap int) [][]float64
- type PwelchOptions

❖

func Pwelch(x []float64, Fs float64, o *PwelchOptions) (Pxx, freqs []float64)

Pwelch estimates the power spectral density of x using Welch's method. Fs is the sampling frequency (samples per time unit) of x. Fs is used to calculate freqs. Returns the power spectral density Pxx and corresponding frequencies freqs. Designed to be similar to the matplotlib implementation below. Reference: http://matplotlib.org/api/mlab_api.html#matplotlib.mlab.psd See also: http://www.mathworks.com/help/signal/ref/pwelch.html

Segment x segmented into segments of length size with specified noverlap. Number of segments returned is (len(x) - size) / (size - noverlap) + 1.

❖

type PwelchOptions struct { // NFFT is the number of data points used in each block for the FFT. Must be // even; a power 2 is most efficient. This should *NOT* be used to get zero // padding, or the scaling of the result will be incorrect. Use Pad for // this instead. // // The default value is 256. NFFT int // Window is a function that returns an array of window values the length // of its input parameter. Each segment is scaled by these values. // // The default (nil) is window.Hann, from the go-dsp/window package. Window func(int) []float64 // Pad is the number of points to which the data segment is padded when // performing the FFT. This can be different from NFFT, which specifies the // number of data points used. While not increasing the actual resolution of // the psd (the minimum distance between resolvable peaks), this can give // more points in the plot, allowing for more detail. // // The value default is 0, which sets Pad equal to NFFT. Pad int // Noverlap is the number of points of overlap between blocks. // // The default value is 0 (no overlap). Noverlap int // Specifies whether the resulting density values should be scaled by the // scaling frequency, which gives density in units of Hz^-1. This allows for // integration over the returned frequency values. The default is set for // MATLAB compatibility. Note that this is the opposite of matplotlib style, // but with equivalent defaults. // // The default value is false (enable scaling). Scale_off bool }

Package spectral imports 5 packages (graph) and is imported by 6 packages. Updated 2019-12-09. Refresh now. Tools for package owners.