Next: Image Processing, Previous: Control Theory, Up: Top

I hope that someday Octave will include more signal processing functions. If you would like to help improve Octave in this area, please contact [email protected].

— Function File: **detrend** (`x, p`)

If

xis a vector,`detrend (`

x`,`

p`)`

removes the best fit of a polynomial of orderpfrom the datax.If

xis a matrix,`detrend (`

x`,`

p`)`

does the same for each column inx.The second argument is optional. If it is not specified, a value of 1 is assumed. This corresponds to removing a linear trend.

— Loadable Function: **fft** (`a, n, dim`)

Compute the FFT of

ausing subroutines from Fftw. The FFT is calculated along the first non-singleton dimension of the array. Thus ifais a matrix,`fft (`

a`)`

computes the FFT for each column ofa.If called with two arguments,

nis expected to be an integer specifying the number of elements ofato use, or an empty matrix to specify that its value should be ignored. Ifnis larger than the dimension along which the FFT is calculated, thenais resized and padded with zeros. Otherwise, ifnis smaller than the dimension along which the FFT is calculated, thenais truncated.If called with three agruments,

dimis an integer specifying the dimension of the matrix along which the FFT is performed

— Loadable Function: **ifft** (`a, n, dim`)

Compute the inverse FFT of

ausing subroutines from Fftw. The inverse FFT is calculated along the first non-singleton dimension of the array. Thus ifais a matrix,`fft (`

a`)`

computes the inverse FFT for each column ofa.If called with two arguments,

nis expected to be an integer specifying the number of elements ofato use, or an empty matrix to specify that its value should be ignored. Ifnis larger than the dimension along which the inverse FFT is calculated, thenais resized and padded with zeros. Otherwise, ifnis smaller than the dimension along which the inverse FFT is calculated, thenais truncated.If called with three agruments,

dimis an integer specifying the dimension of the matrix along which the inverse FFT is performed

— Loadable Function: **fft2** (`a, n, m`)

Compute the two dimensional FFT of

ausing subroutines from Fftw. The optional argumentsnandmmay be used specify the number of rows and columns ofato use. If either of these is larger than the size ofa,ais resized and padded with zeros.If

ais a multi-dimensional matrix, each two-dimensional sub-matrix ofais treated seperately

— Loadable Function: **fft2** (`a, n, m`)

Compute the inverse two dimensional FFT of

ausing subroutines from Fftw. The optional argumentsnandmmay be used specify the number of rows and columns ofato use. If either of these is larger than the size ofa,ais resized and padded with zeros.If

ais a multi-dimensional matrix, each two-dimensional sub-matrix ofais treated seperately

— Loadable Function: **fftn** (`a, size`)

Compute the N dimensional FFT of

ausing subroutines from Fftw. The optional vector argumentsizemay be used specify the dimensions of the array to be used. If an element ofsizeis smaller than the corresponding dimension, then the dimension is truncated prior to performing the FFT. Otherwise if an element ofsizeis larger than the corresponding dimensionais resized and padded with zeros.

— Loadable Function: **ifftn** (`a, size`)

Compute the invesre N dimensional FFT of

ausing subroutines from Fftw. The optional vector argumentsizemay be used specify the dimensions of the array to be used. If an element ofsizeis smaller than the corresponding dimension, then the dimension is truncated prior to performing the inverse FFT. Otherwise if an element ofsizeis larger than the corresponding dimensionais resized and padded with zeros.

— Function File: **fftconv** (`a, b, n`)

Return the convolution of the vectors

aandb, as a vector with length equal to the`length (a) + length (b) - 1`

. Ifaandbare the coefficient vectors of two polynomials, the returned value is the coefficient vector of the product polynomial.The computation uses the FFT by calling the function

`fftfilt`

. If the optional argumentnis specified, an N-point FFT is used.

— Function File: **fftfilt** (`b, x, n`)

With two arguments,

`fftfilt`

filtersxwith the FIR filterbusing the FFT.Given the optional third argument,

n,`fftfilt`

uses the overlap-add method to filterxwithbusing an N-point FFT.If

xis a matrix, filter each column of the matrix.

— Loadable Function: y = **filter** (`b, a, x`)

— Loadable Function: [`y`, `sf`] = **filter** (`b, a, x, si`)

— Loadable Function: [`y`, `sf`] = **filter** (`b, a, x, `[]`, dim`)

— Loadable Function: [`y`, `sf`] = **filter** (`b, a, x, si, dim`)

— Loadable Function: [

— Loadable Function: [

— Loadable Function: [

Return the solution to the following linear, time-invariant difference equation:

N M SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k) for 1<=n<=length(x) k=0 k=0where N=length(a)-1 and M=length(b)-1. over the first non-singleton dimension of

xor overdimif supplied. An equivalent form of this equation is:N M y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k) for 1<=n<=length(x) k=1 k=0where c = a/a(1) and d = b/a(1).

If the fourth argument

siis provided, it is taken as the initial state of the system and the final state is returned assf. The state vector is a column vector whose length is equal to the length of the longest coefficient vector minus one. Ifsiis not supplied, the initial state vector is set to all zeros.In terms of the z-transform, y is the result of passing the discrete- time signal x through a system characterized by the following rational system function:

M SUM d(k+1) z^(-k) k=0 H(z) = ---------------------- N 1 + SUM c(k+1) z(-k) k=1

— Function File: [`h`, `w`] = **freqz** (`b, a, n, "whole"`)

Return the complex frequency response

hof the rational IIR filter whose numerator and denominator coefficients arebanda, respectively. The response is evaluated atnangular frequencies between 0 and 2*pi.The output value

wis a vector of the frequencies.If the fourth argument is omitted, the response is evaluated at frequencies between 0 and pi.

If

nis omitted, a value of 512 is assumed.If

ais omitted, the denominator is assumed to be 1 (this corresponds to a simple FIR filter).For fastest computation,

nshould factor into a small number of small primes. — Function File:h=freqz(b, a, w)

Evaluate the response at the specific frequencies in the vector

w. The values forware measured in radians. — Function File: [...] =freqz(..., Fs)

Return frequencies in Hz instead of radians assuming a sampling rate

Fs. If you are evaluating the response at specific frequenciesw, those frequencies should be requested in Hz rather than radians. — Function File:freqz(...)

Plot the pass band, stop band and phase response of

hrather than returning them.

— Function File: `b` = **unwrap** (`a, tol, dim`)

Unwrap radian phases by adding multiples of 2*pi as appropriate to remove jumps greater than

tol.toldefaults to pi.Unwrap will unwrap along the first non-singleton dimension of

a, unless the optional argumentdimis given, in which case the data will be unwrapped along this dimension

— Function File: [`a`, `b`] = **arch_fit** (`y, x, p, iter, gamma, a0, b0`)

Fit an ARCH regression model to the time series

yusing the scoring algorithm in Engle's original ARCH paper. The model isy(t) = b(1) * x(t,1) + ... + b(k) * x(t,k) + e(t), h(t) = a(1) + a(2) * e(t-1)^2 + ... + a(p+1) * e(t-p)^2in which e(t) is N(0, h(t)), given a time-series vector

yup to time t-1 and a matrix of (ordinary) regressorsxup to t. The order of the regression of the residual variance is specified byp.If invoked as

`arch_fit (`

y`,`

k`,`

p`)`

with a positive integerk, fit an ARCH(k,p) process, i.e., do the above with the t-th row ofxgiven by[1, y(t-1), ..., y(t-k)]Optionally, one can specify the number of iterations

iter, the updating factorgamma, and initial values a0 and b0 for the scoring algorithm.

— Function File: **arch_rnd** (`a, b, t`)

Simulate an ARCH sequence of length

twith AR coefficientsband CH coefficientsa. I.e., the result y(t) follows the modely(t) = b(1) + b(2) * y(t-1) + ... + b(lb) * y(t-lb+1) + e(t),where e(t), given

yup to time t-1, is N(0, h(t)), withh(t) = a(1) + a(2) * e(t-1)^2 + ... + a(la) * e(t-la+1)^2

— Function File: [`pval`, `lm`] = **arch_test** (`y, x, p`)

For a linear regression model

y = x * b + eperform a Lagrange Multiplier (LM) test of the null hypothesis of no conditional heteroscedascity against the alternative of CH(

p).I.e., the model is

y(t) = b(1) * x(t,1) + ... + b(k) * x(t,k) + e(t),given

yup to t-1 andxup to t, e(t) is N(0, h(t)) withh(t) = v + a(1) * e(t-1)^2 + ... + a(p) * e(t-p)^2,and the null is a(1) == ... == a(p) == 0.

If the second argument is a scalar integer, k, perform the same test in a linear autoregression model of order k, i.e., with

[1, y(t-1), ..., y(t-k)]as the t-th row of

x.Under the null, LM approximately has a chisquare distribution with

pdegrees of freedom andpvalis the p-value (1 minus the CDF of this distribution at LM) of the test.If no output argument is given, the p-value is displayed.

— Function File: **arma_rnd** (`a, b, v, t, n`)

Return a simulation of the ARMA model

x(n) = a(1) * x(n-1) + ... + a(k) * x(n-k) + e(n) + b(1) * e(n-1) + ... + b(l) * e(n-l)in which

kis the length of vectora,lis the length of vectorbandeis gaussian white noise with variancev. The function returns a vector of lengtht.The optional parameter

ngives the number of dummyx(i) used for initialization, i.e., a sequence of lengtht+nis generated andx(n+1:t+n) is returned. Ifnis omitted,n= 100 is used.

— Function File: **autocor** (`x, h`)

Return the autocorrelations from lag 0 to

hof vectorx. Ifhis omitted, all autocorrelations are computed. Ifxis a matrix, the autocorrelations of each column are computed.

— Function File: **autocov** (`x, h`)

Return the autocovariances from lag 0 to

hof vectorx. Ifhis omitted, all autocovariances are computed. Ifxis a matrix, the autocovariances of each column are computed.

— Function File: **autoreg_matrix** (`y, k`)

Given a time series (vector)

y, return a matrix with ones in the first column and the firstklagged values ofyin the other columns. I.e., fort>k,`[1,`

y`(`

t`-1), ...,`

y`(`

t`-`

k`)]`

is the t-th row of the result. The resulting matrix may be used as a regressor matrix in autoregressions.

— Function File: **bartlett** (`m`)

Return the filter coefficients of a Bartlett (triangular) window of length

m.For a definition of the Bartlett window, see e.g. A. V. Oppenheim & R. W. Schafer, "Discrete-Time Signal Processing".

— Function File: **blackman** (`m`)

Return the filter coefficients of a Blackman window of length

m.For a definition of the Blackman window, see e.g. A. V. Oppenheim & R. W. Schafer, "Discrete-Time Signal Processing".

— Function File: [`d`, `dd`] **=**` diffpara `(`x, a, b`)

Return the estimator

dfor the differencing parameter of an integrated time series.The frequencies from [2*pi*a/t, 2*pi*b/T] are used for the estimation. If

bis omitted, the interval [2*pi/T, 2*pi*a/T] is used. If bothbandaare omitted then a = 0.5 * sqrt (T) and b = 1.5 * sqrt (T) is used, where T is the sample size. Ifxis a matrix, the differencing parameter of each column is estimated.The estimators for all frequencies in the intervals described above is returned in

dd. The value ofdis simply the mean ofdd.Reference: Brockwell, Peter J. & Davis, Richard A. Time Series: Theory and Methods Springer 1987.

— Function File: **durbinlevinson** (`c, oldphi, oldv`)

Perform one step of the Durbin-Levinson algorithm.

The vector

cspecifies the autocovariances`[gamma_0, ..., gamma_t]`

from lag 0 tot,oldphispecifies the coefficients based onc(t-1) andoldvspecifies the corresponding error.If

oldphiandoldvare omitted, all steps from 1 totof the algorithm are performed.

— Function File: **fftshift** (`v`)

— Function File:**fftshift** (`v, dim`)

— Function File:

Perform a shift of the vector

v, for use with the`fft`

and`ifft`

functions, in order the move the frequency 0 to the center of the vector or matrix.If

vis a vector of N elements corresponding to N time samples spaced of Dt each, then`fftshift (fft (`

v`))`

corresponds to frequenciesf = ((1:N) - ceil(N/2)) / N / DtIf

vis a matrix, the same holds for rows and columns. Ifvis an array, then the same holds along each dimension.The optional

dimargument can be used to limit the dimension along which the permutation occurs.

— Function File: **fractdiff** (`x, d`)

Compute the fractional differences (1-L)^d x where L denotes the lag-operator and d is greater than -1.

— Function File: **hamming** (`m`)

Return the filter coefficients of a Hamming window of length

m.For a definition of the Hamming window, see e.g. A. V. Oppenheim & R. W. Schafer, "Discrete-Time Signal Processing".

— Function File: **hanning** (`m`)

Return the filter coefficients of a Hanning window of length

m.For a definition of this window type, see e.g. A. V. Oppenheim & R. W. Schafer, "Discrete-Time Signal Processing".

— Function File: **hurst** (`x`)

Estimate the Hurst parameter of sample

xvia the rescaled range statistic. Ifxis a matrix, the parameter is estimated for every single column.

— Function File: **periodogram** (`x`)

For a data matrix

xfrom a sample of sizen, return the periodogram.

— Function File: **rectangle_lw** (`n, b`)

Rectangular lag window. Subfunction used for spectral density estimation.

— Function File: **rectangle_sw** (`n, b`)

Rectangular spectral window. Subfunction used for spectral density estimation.

— Function File: **sinetone** (`freq, rate, sec, ampl`)

Return a sinetone of frequency

freqwith length ofsecseconds at sampling raterateand with amplitudeampl. The argumentsfreqandamplmay be vectors of common size.Defaults are

rate= 8000,sec= 1 andampl= 64.

— Function File: **sinewave** (`m, n, d`)

Return an

m-element vector withi-th element given by`sin (2 * pi * (`

i`+`

d`-1) /`

n`)`

.The default value for

dis 0 and the default value fornism.

— Function File: **spectral_adf** (`c, win, b`)

Return the spectral density estimator given a vector of autocovariances

c, window namewin, and bandwidth,b.The window name, e.g.,

`"triangle"`

or`"rectangle"`

is used to search for a function calledwin`_sw`

.If

winis omitted, the triangle window is used. Ifbis omitted,`1 / sqrt (length (`

x`))`

is used.

— Function File: **spectral_xdf** (`x, win, b`)

Return the spectral density estimator given a data vector

x, window namewin, and bandwidth,b.The window name, e.g.,

`"triangle"`

or`"rectangle"`

is used to search for a function calledwin`_sw`

.If

winis omitted, the triangle window is used. Ifbis omitted,`1 / sqrt (length (`

x`))`

is used.

— Function File: [`y`, `c`] **=**` stft `(`x, win_size, inc, num_coef, w_type`)

Compute the short-term Fourier transform of the vector

xwithnum_coefcoefficients by applying a window ofwin_sizedata points and an increment ofincpoints.Before computing the Fourier transform, one of the following windows is applied:

- hanning
- w_type = 1
- hamming
- w_type = 2
- rectangle
- w_type = 3
The window names can be passed as strings or by the

w_typenumber.If not all arguments are specified, the following defaults are used:

win_size= 80,inc= 24,num_coef= 64, andw_type= 1.

y`= stft (`

x`, ...)`

returns the absolute values of the Fourier coefficients according to thenum_coefpositive frequencies.

`[`

y`,`

c`] = stft (x, ...)`

returns the entire STFT-matrixyand a 3-element vectorccontaining the window size, increment, and window type, which is needed by the synthesis function.

— Function File: **synthesis** (`y, c`)

Compute a signal from its short-time Fourier transform

yand a 3-element vectorcspecifying window size, increment, and window type.The values

yandccan be derived by[y,c] = stft (x, ...)

— Function File: **triangle_lw** (`n, b`)

Triangular lag window. Subfunction used for spectral density estimation.