The sapaclisp Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The sapaclisp Reference Manual

This is the sapaclisp Reference Manual, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 12:32:44 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

1.1 sapaclisp

Source

sapaclisp.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

2 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

2.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.1 sapaclisp.asd

Location

sapaclisp.asd

Systems

sapaclisp (system)

Packages

sapaclisp-asd


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.2 sapaclisp/sapa-package.lisp

Parent

sapaclisp (system)

Location

sapa-package.lisp

Packages

sapa


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.3 sapaclisp/hacks.lisp

Dependency

sapa-package.lisp (file)

Parent

sapaclisp (system)

Location

hacks.lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.4 sapaclisp/utilities.lisp

Dependency

sapa-package.lisp (file)

Parent

sapaclisp (system)

Location

utilities.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.5 sapaclisp/matrix.lisp

Dependency

sapa-package.lisp (file)

Parent

sapaclisp (system)

Location

matrix.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.6 sapaclisp/basic-math.lisp

Dependency

sapa-package.lisp (file)

Parent

sapaclisp (system)

Location

basic-math.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.7 sapaclisp/dft-and-fft.lisp

Dependency

utilities.lisp (file)

Parent

sapaclisp (system)

Location

dft-and-fft.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.8 sapaclisp/basic-statistics.lisp

Dependencies
Parent

sapaclisp (system)

Location

basic-statistics.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.9 sapaclisp/random.lisp

Dependencies
Parent

sapaclisp (system)

Location

random.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.10 sapaclisp/tapers.lisp

Dependencies
Parent

sapaclisp (system)

Location

tapers.lisp

Exported Definitions
Internal Definitions

bessi0-nr (function)


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.11 sapaclisp/filtering.lisp

Dependencies
Parent

sapaclisp (system)

Location

filtering.lisp

Exported Definitions
Internal Definitions

which-is-faster? (function)


Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.12 sapaclisp/acvs.lisp

Dependencies
Parent

sapaclisp (system)

Location

acvs.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.13 sapaclisp/parametric.lisp

Dependencies
Parent

sapaclisp (system)

Location

parametric.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.14 sapaclisp/multitaper.lisp

Dependencies
Parent

sapaclisp (system)

Location

multitaper.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

2.1.15 sapaclisp/nonparametric.lisp

Dependencies
Parent

sapaclisp (system)

Location

nonparametric.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

2.1.16 sapaclisp/harmonic.lisp

Dependencies
Parent

sapaclisp (system)

Location

harmonic.lisp

Exported Definitions

Next: , Previous: , Up: Top   [Contents][Index]

3 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

3.1 sapaclisp-asd

Source

sapaclisp.asd

Use List

Previous: , Up: Packages   [Contents][Index]

3.2 sapa

Source

sapa-package.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

4.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

4.1.1 Macros

Macro: divf PLACE &optional DELTA

Like <incf>

Package

sapa

Source

utilities.lisp (file)

Macro: multf PLACE &optional DELTA

Like <incf>

Package

sapa

Source

utilities.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

4.1.2 Functions

Function: 2d-matrix->linearized-upper-trangular A &key RESULT

given
[1] A (required)
==> a 2d hermitian matrix
[2] result (keyword; new vector of appropriate size) <== a vector filled linearly with elements of A
converts 2d hermitian array into linearized form and returns
[1] result, a vector with 2d hermitian array stored in linearized form

Package

sapa

Source

matrix.lisp (file)

Function: 2d-matrix-move! FROM-THIS TO-THIS

given
[1] from-this (required)
==> a 2d matrix
[2] to-this (required)
<== another 2d matrix
transfer contents of from-this to corresponding locations in to-this, and
returns
[1] to-this

Package

sapa

Source

matrix.lisp (file)

Function: a*x A X

given
[1] a (required)
==> a number
[2] x (required)
==> a sequence of numbers
returns
[1] a vector of numbers obtained by multiplying each element of x by a
—-
Note: corresponds to SSCAL in LINPACK’s bla.

Package

sapa

Source

utilities.lisp (file)

Function: a*x! A X &key RESULT

given
[1] a (required)
==> a number
[2] x (required)
==> a sequence of numbers
[2] result (keyword; x)
<== a sequence of numbers
returns
[1] a sequence of numbers obtained by multiplying each element of x by a
—-
Note: corresponds to SSCAL in LINPACK’s bla.

Package

sapa

Source

utilities.lisp (file)

Function: a*x+b A X B

given
[1] a (required)
==> a number
[2] x (required)
==> a sequence of numbers
[3] b (required)
==> a number
returns
[1] a vector of numbers obtained by multiplying each element of x by a and adding b

Package

sapa

Source

utilities.lisp (file)

Function: a*x+b! A X B &key RESULT

given
[1] a (required)
==> a number
[2] x (required)
==> a sequence of numbers
[3] b (required)
==> a number
[4] result (keyword; x)
<== a sequence of numbers
returns
[1] a sequence of numbers obtained by multiplying each element of x by a and adding b

Package

sapa

Source

utilities.lisp (file)

Function: a*x+y A X Y

given
[1] a (required)
==> a number
[2] x (required)
==> a sequence of numbers
[3] y (required)
==> a sequence of numbers
returns
[1] a vector of numbers obtained by multiplying each element of x by a and adding the corresponding element of y
—-
Note: corresponds to SAXPY in LINPACK’s bla.

Package

sapa

Source

utilities.lisp (file)

Function: a*x+y! A X Y &key RESULT

given
[1] a (required)
==> a number
[2] x (required)
==> a sequence of numbers
[3] y (required)
==> a sequence of numbers
[4] result (keyword; y)
<== a sequence of numbers
returns
[1] a sequence of numbers obtained by multiplying each element of x by a and adding the corresponding element of y
—-
Note: corresponds to SAXPY in LINPACK’s bla.

Package

sapa

Source

utilities.lisp (file)

Function: acvs TIME-SERIES &key START END CENTER-DATA-P ACS-P RESULT

given
[1] time-series (required)
==> a vector containing the time series
[2] start (keyword; 0)
==> start index of time-series to be used
[3] end (keyword; length of time-series)
==> 1 + end index of time-series to be used
[4] center-data-p (keyword; t)
==> if t, subtract sample mean of time series
prior to computing the acvs;
if nil, do not subtract the sample mean
[5] acs-p (keyword; nil)
==> return autocorrelation sequence
rather than autocovariance sequence
[6] result (keyword; vector of length n)
<== vector to hold acvs (or acs)
calculates autocovariance (or autocorrelation) sequence using fft’s and returns
[1] result, a vector with the sample acvs (or acs)
[2] sample variance of time series (with mean treated
as specified by center-data-p keyword)

Note: see Equations (191a) and (190b) of the SAPA book

Package

sapa

Source

acvs.lisp (file)

Function: acvs-for-time-series-simulated-from-sdf N-SERIES SDF &key SAMPLING-TIME N-TOTAL RESULT

given
[1] n-series (required)
==> length of time series simulated using simulate-time-series-from-sdf
(must be a power of 2)
[2] sdf (required)
==> spectral density function (sdf) defined for
0 <= f <= 1/(2.0 sampling-time) – the
sdf is assumed to be two-sided and symmetric about f = 0
[3] sampling-time (keyword; 1.0)
==> the assumed sampling time (delta t)
[4] n-total (keyword; 4 * next power of 2 for n-series) ==> a power of 2 controlling degree of accuracy
of the approximation (the larger, the better – see Percival, 1992, for details)
[5] result (keyword; vector of length n-series)
<== a vector to contain simulated time series returns
[1] a vector with the theoretical acvs from lag 0
to n-series - 1 for a time series generated via a call to simulate-time-series-from-sdf with n-series, sdf, sampling-time and n-total set to the same values

Package

sapa

Source

random.lisp (file)

Function: add-sequences &rest SEQS

given
[1] a arbitrary number of sequences of numbers, all of the same size
returns
[1] a new sequence formed by adding the sequences together on an element by element basis

Package

sapa

Source

utilities.lisp (file)

Function: ar-coeffs->acvs AR-COEFFS VARIANCE MAX-LAG &key PROCESS-VARIANCE-P LIST-OF-LOWER-ORDER-PHI LIST-OF-LOWER-ORDER-PEV RESULT

given
[1] AR-coeffs (required)
==> vector of length p with real or
complex-valued AR coefficients phi_{j,p}
for an AR(p) model of order p:
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2}
+ ... + phi_{p,p} * x_{t-p} + e_t
[2] variance (required)
==> process variance (if process-variance-p is true)
or innovations variance (if nil)
[3] max-lag (required)
==> acvs to be computed out to this lag
[4] process-variance-p (keyword; t)
==> if true, required variance parameter
is taken to be process variance;
otherwise, it is taken to be the innovations
variance (both variance and process-variance-p
are ignored if the next two keyword parameters
are supplied)
[5] list-of-lower-order-phi (keyword; nil)
==> if supplied, bypasses call to step-down-Levinson-Durbin-recursions, in which case list-of-lower-order-pev must be supplied also
[6] list-of-lower-order-pev (keyword; nil)
==> if supplied, bypasses call to step-down-Levinson-Durbin-recursions [7] result (keyword; vector of size max-lag + 1)
<== vector to hold acvs for lags 0, 1, ..., max-lag
returns
[1] result, i.e., the acvs

Note: see Section 9.4 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: ar-coeffs->prewhitening-filter AR-COEFFS &key RESULT

given
[1] AR-coeffs (required)
==> a sequence of AR coefficients
phi_{1,p}, ..., phi_{p,p}
[2] result (keyword; vector of size (1+ (length AR-coeffs))) <== sequence to hold coefficients for prewhitening filter 1, -phi_{1,p}, ..., -phi_{p,p}
returns
[1] result, the prewhitening filter

Note: this filter can be used to compute
forward prediction errors; to obtain
the filter needed to compute
backward prediction errors,
reverse the elements in result; i.e.,
evaluate (reverse result)

Package

sapa

Source

parametric.lisp (file)

Function: ar-coeffs->reflection-coeffs AR-COEFFS &key LIST-OF-LOWER-ORDER-PHI RESULT

given
[1] AR-coeffs (required)
==> vector of length p with real or
complex-valued AR coefficients phi_{j,p}
for an AR(p) model of order p:
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2}
+ ... + phi_{p,p} * x_{t-p} + e_t
[2] list-of-lower-order-phi (keyword; calls step-down-Levinson-Durbin-recursions) ==> must contain the list that is returned by
the function step-down-Levinson-Durbin-recursions;
this keyword parameter is useful if the result
of calling that function is already available
[3] results (keyword; vector of length p)
<== vector of size p into which
the reflection coefficients phi_{j,j}
of orders j = 1, 2, ..., p are placed
returns
[1] results, i.e., the reflection coefficients

Note: see Section 9.4 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: ar-coeffs->sdf AR-COEFFS INNOVATIONS-VARIANCE &key N-NONZERO-FREQS SAMPLING-TIME RETURN-EST-FOR-0-FREQ-P SDF-TRANSFORMATION RESULT-SDF RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] AR-coeffs (required)
==> vector with real-valued AR coefficients phi_{j,p}
for an AR(p) model of order p:
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2}
+ ... + phi_{p,p} * x_{t-p} + e_t
[2] innovations-variance (required)
==> innovations variance of the process
[3] N-nonzero-freqs (keyword; 256)
==> the number of nonzero frequencies at which the AR sdf
is to be computed (need NOT be a power of 2);
the first nonzero frequency (and also spacing
between frequencies) is given by
1/(2 * N-nonzero-freqs * sampling time)
= Nyquist frequency/N-nonzero-freqs;
the last nonzero frequency is the Nyquist frequency
[4] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[5] return-est-for-0-freq-p (keyword; t)
==> if t, sdf is computed at zero frequency;
otherwise, it is not computed.
[6] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[7] result-sdf (keyword; vector of correct length)
<== vector of length N-nonzero-freqs (if return-est-for-0-freq-p is nil) or N-nonzero-freqs +1 (if return-est-for-0-freq-p is t)
into which the properly transformed sdf is placed
[8] return-frequencies-p (keyword; nil)
==> if t, the frequencies associated with the transfer function
are computed and returned in result-freq
[9] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
(ignored unless return-frequencies-p is true)
[10] result-freq (keyword; nil or vector of correct length)
<== not used if return-frequencies-p nil; otherwise,
vector of length N-nonzero-freqs (if return-est-for-0-freq-p is nil) or N-nonzero-freqs +1 (if return-est-for-0-freq-p is t)
into which the frequencies associated with the values
in result-sdf are placed
returns
[1] result-sdf, a vector holding
the properly transformed sdf
[2] nil (if return-frequencies-p is nil) or
result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the properly transformed frequencies
associated with values in result-sdf
[3] the length of the vector result-sdf

Note: see Equation (392b) of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: ar-coeffs->sdf-at-single-freq AR-COEFFS INNOVATIONS-VARIANCE FREQ &key SAMPLING-TIME SDF-TRANSFORMATION

given
[1] AR-coeffs (required)
==> vector with real-valued AR coefficients phi_{j,p} for an AR(p) model of order p:
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2} + ... + phi_{p,p} * x_{t-p} + e_t
[2] innovations-variance (required)
==> innovations variance of the process
[3] freq (required)
==> the single frequency at which the sdf is
to be computed
[4] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book) [6] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used to transform the value of the sdf at freq returns
[1] properly transformed AR sdf evaluated at freq
[2] nil (if return-frequencies-p is nil) or result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the properly transformed frequencies
associated with values in result-sdf
[3] the length of the vector result-sdf

Note: see Equation (392b) of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: ar-coeffs->variance AR-COEFFS INNOVATIONS-VARIANCE

given
[1] AR-coeffs (required)
==> a sequence of AR coefficients phi_{1,p}, ..., phi_{p,p}
[2] innovations-variance (required)
==> innovations variance of the process returns
[1] variance of the process

Package

sapa

Source

parametric.lisp (file)

Function: bandwidth&confidence-intervals-for-sdf-db SDF-DB FREQ SAMPLE-SIZE &key CONFIDENCE-LEVEL LAG-WINDOW-FUNCTION MAX-LAG SAMPLING-TIME C_H

given
[1] sdf-dB (required)
==> an sdf estimate (in decibels) for a single frequency
[2] freq (required)
==> the frequency associated with sdf-dB
[3] sampling-size (required)
==> the sample size of the time series
from which sdf-dB was computed
[4] confidence-level (keyword; 0.95)
==> the level of the confidence interval
(e.g., 0.95 yields a 95% confidence interval)
[5] lag-window-function (keyword; nil)
==> the lag window function used to create
sdf-dB (nil means a lag window function was NOT used) [6] max-lag (keyword; sample-size - 1)
==> the maximum lag used in conjunction with lag-window-function to create sdf-dB (not used in lag-window-function is nil) [7] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[8] C_h (keyword; 1.0)
==> the variance inflation factor due to tapering
(see Table 248 of the SAPA book); the default value
of 1.0 is appropriate for a rectangular data taper returns
[1] left-hand size of interval describing the bandwidth of
the spectral estimate (interval is centered on freq)
[2] right-hand size of bandwidth interval
[3] lower limit (in decibels) of confidence interval for
true sdf based upon sdf-dB
[4] upper limit (in decibels) of confidence interval

Note: see Sections 6.7 and 6.10 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: bartlett-bandwidth->m B_W &key SAMPLING-TIME

given desired smoothing window bandwidth B_W and sampling time, returns
[1] window parameter m required to approximately achieve B_W using the Bartlett lag window
[2] actual B_W achieved

Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: bartlett-lag-window TAU M

given the lag tau and window parameter m, returns the value of the Bartlett lag window —
Note: see Equation (260) of the SAPA book or Priestley, page 439, Equation (6.2.65)

Package

sapa

Source

nonparametric.lisp (file)

Function: bartlett-m->bandwidth M &key SAMPLING-TIME

given window parameter m and sampling time,
returns bandwidth B_W for the Bartlett smoothing window —
Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: bartlett-n-m->degrees-of-freedom N M &key C_H

given sample size N, window parameter m and variance inflation factor C_h, returns equivalent degrees of freedom nu for Bartlett lag window

Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: biased-acvs->unbiased-acvs BIASED-ACVS

given a biased estimate of the acvs, returns the corresponding unbiased estimate

Package

sapa

Source

acvs.lisp (file)

Function: binary-search VALUE ORDERED-SEQ &key LOWER-TEST UPPER-TEST

given
[1] value (required)
==> a real-valued number
[2] ordered-seq (required)
==> an ordered sequence of real-valued numbers
[3] lower-test (keyword; #’<=)
==> a predicate of two arguments
that defines the lower test
[4] upper-test (keyword; #’<=)
==> a predicate of two arguments
that defines the upper test
returns
[1] if lower-test and upper-test are set
to their default values, this function
returns an index i such that v[i] <= value <= v[i+1],
where 0 <= i <= n-2 (if there is no such i, nil is returned); if nondefault values are supplied for lower-test and upper-test, then the condition ‘v[i] <= value <= v[i+1]’
gets modified in an obvious way

Note: value can be an arbitrary object, and ordered-seq
can be a list of arbitrary objects if the binary predicates lower-test and upper-test are appropriate set

Package

sapa

Source

utilities.lisp (file)

Function: bisection-with-newton-raphson F F-PRIME X-LEFT X-RIGHT &key ACCURACY MAXIMUM-NUMBER-OF-ITERATIONS

given
[1] f (required)
==> a function with a single argument
[2] f-prime (required)
==> another function with a single argument, this one being the first derivative of f [3] x-left (required)
==> left-hand bracket for the desired root; i.e., left-hand bracket <= desired root [4] x-right (required)
==> right-hand bracket for the desired root; i.e., desired root <= right-hand bracket [5] accuracy (keyword; (* 10.0 single-float-epsilon)) ==> desired relative accuracy for computed rood [6] maximum-number-of-iterations (keyword; 100) ==> maximum number of iterations
returns
[1] a root of f in [x-left, x-right];
i.e., a value x in that interval
such that f(x) = 0
[2] the number of iterations required

Note: this function is based loosely on rtsafe, Section 9.4, Numerical Recipes, Second Edition

Package

sapa

Source

basic-math.lisp (file)

Function: box-plot A-SEQ &key SEQ-SORTED-P GET-BOTTOM-LINE GET-BOTTOM-OF-BOX GET-LINE-THROUGH-BOX GET-TOP-OF-BOX GET-TOP-LINE

given
[1] a-seq (required)
==> a sequence of real-valued numbers
[2] seq-sorted-p (keyword; nil)
==> if t, a-seq is already sorted;
if nil, a copy of a-seq is sorted
for use by the function
[3] get-bottom-line (keyword; computes lower adjacent value) ==> a function for calculating
the line below the box (from sorted data)
[4] get-bottom-of-box (keyword; computes lower quartile) ==> a function for calculating
bottom of the box
[5] get-line-through-box (keyword; computes median)
==> a function for calculating
the line through the middle of the box
[6] get-top-of-box (keyword; computes upper quartile) ==> a function for calculating
top of the box
[7] get-top-line (keyword; computes upper adjacent value) ==> a function for calculating
the line above the box
returns
[1] bottom line below box
[2] bottom line of box
[3] line through middle of box
[4] top line of box
[5] top line above box
[6] a vector containing outside values
(note: this vector can be of length 0)

Note: the values that this function returns can
be used to contruct a box plot as defined in
Section 2.5 of “Graphical Methods for Data Analysis” by Chambers, Cleveland, Kleiner, Tukey

Package

sapa

Source

basic-statistics.lisp (file)

Function: burg-algorithm TIME-SERIES P &key START END CENTER-DATA AR-COEFFS APPROXIMATE-MSES REFLECTION-COEFFS FORWARD-PREDICTION-ERRORS BACKWARD-PREDICTION-ERRORS EXACT-MSES

given
[1] time-series (required)
==> a vector containing a real-valued or
complex-valued time series x_t
[2] p (required)
==> autoregressive model order;
p should be an integer > 0 and < end - start
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of vector to be used
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series;
if nil, the effect of this function is to return
a copy of the relevant portion of time-series
[6] AR-coeffs (keyword; a vector of length p)
<== estimates of AR coefficients phi_{1,p}, ..., phi_{p,p}
[7] approximate-MSEs (keyword; a vector of length p+1)
<== estimates of innovations variance (mean square errors)
for models of order 0, 1, ..., p (the innovations variance
for the zeroth order model is the sample variance)
[8] reflection-coeffs (keyword; a vector of length p)
<== estimates of reflection coefficients phi_{1,1}, ..., phi_{p,p} [9] forward-prediction-errors (keyword; a vector of length end - start - p) <== computed forward prediction errors
[10] backward-prediction-errors (keyword; a vector of length end - start - p) <== computed backward prediction errors
[11] exact-MSEs (keyword; a vector of length p+1)
<== another set of estimates of innovations variance
for models of order 0, 1, ..., p; these estimates
are based on Equation (419a) of the SAPA book
uses Burg’s algorithm to estimate the phi’s in the model
x_t = phi_{1,p} x_{t-1} + ... + phi_{p,p} x_{t-p} + e_t
and returns
[1] AR-coeffs, a vector containing phi_{1,p}, ..., phi_{p,p}
[2] estimate of the innovations variance, i.e.,
the variance of the e_t’s; this number is also given in
(elt approximate-MSEs p)
[3] approximate-MSEs
[4] reflection-coeffs
[5] forward-prediction-errors
[6] backward-prediction-errors
[7] exact-MSEs

Note: see Section 9.5 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: careful-convert-to-db NUM &optional ZERO-MAPPING

given
[1] num (required)
==> a number
[1] zero-mapping (required) ==> a number
returns
[1] 10 log_10(num) if num > 0 or zero-mapping if num <= 0

Package

sapa

Source

utilities.lisp (file)

Function: center&prewhiten&taper-time-series TIME-SERIES &key CENTER-DATA START END PREWHITENING-FILTER RECENTER-AFTER-PREWHITENING-P DATA-TAPER DATA-TAPER-PARAMETERS RECENTER-AFTER-TAPERING-P RESTORE-POWER-OPTION-P RESULT

given
[1] time-series (required)
==> a sequence of time series values
[2] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, time-series is not centered
[3] start (keyword; 0)
==> start index of sequence to be used
[4] end (keyword; length of time-series)
==> 1 + end index of sequence to be used
[5] prewhitening-filter (keyword; nil)
==> vector with coeffients of prewhitening filter
or nil (if no prewhitening is to be done)
[6] recenter-after-prewhitening-p (keyword; t)
==> if t, prewhitened series is centered using sample mean (not used if prewhitening-filter is nil)
[7] data-taper (keyword; nil)
==> nil or a tapering function
[8] data-taper-parameters (keyword)
==> parameters for tapering function (not used
if data-taper is nil)
[9] recenter-after-tapering-p (keyword; t)
==> if t and data-taper is a function,
centers tapered series by subtracting
off its sample mean
[10] restore-power-option-p (keyword; t)
==> if t and data-taper is a function,
normalizes tapered series to have same
sum of squares as before tapering
[11] result (keyword; vector of size (- end start))
<== sequence to hold centered, prewhitened
and tapered time series
returns
[1] result, the sequence containing the centered, prewhitened and tapered time series (time-series are unaltered unless it is bound to result)
[2] the number used to center the time series
(this is nil if center-data is nil)
[3] C_h, the variance inflation factor due to the data taper —
Note: see also center&taper-time-series in tapers.lisp

Package

sapa

Source

filtering.lisp (file)

Function: center&taper-time-series TIME-SERIES &key CENTER-DATA START END DATA-TAPER DATA-TAPER-PARAMETERS RECENTER-AFTER-TAPERING-P RESTORE-POWER-OPTION-P RESULT

given
[1] time-series (required)
==> a sequence of time series values
[2] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, the effect of this function is to return a copy of the relevant portion of time-series [3] start (keyword; 0)
==> start index of sequence to be used
[4] end (keyword; length of time-series)
==> 1 + end index of sequence to be used
[5] data-taper (keyword; nil)
==> nil or a tapering function
[6] data-taper-parameters (keyword)
==> parameters for tapering function (not used
if data-taper is nil)
[7] recenter-after-tapering-p (keyword; t)
==> if t and data-taper is a function,
centers tapered series by subtracting
off its sample mean
[8] restore-power-option-p (keyword; t)
==> if t and data-taper is a function,
normalizes tapered series to have same
sum of squares as before tapering
[9] result (keyword; vector of size (- end start))
<== sequence to hold centered time series
returns
[1] result, the sequence containing the centered and/or tapered time series (the contents of time-series
are unaltered unless it is also bound to result)
[2] the number used to center the time series
(this is nil if center-data is nil)
[3] C_h, the variance inflation factor due to the data taper —
Note: see also center&prewhiten&taper-time-series
in filtering.lisp

Package

sapa

Source

tapers.lisp (file)

Function: cepstrum->i_m CEPSTRUM &key SAMPLING-TIME N-PRIME LAG-WINDOW-FUNCTION LAMBDA-FACTOR RESULT

given
[1] cepstrum (required)
==> a vector of length N_U+1 with values of the cepstrum from lag 0 to N_U
[2] sampling-time (keyword; 1.0)
==> the sample time (i.e., delta t)
[3] N-prime (keyword; 2 * N_U)
==> effective sample size, as discussed in Section 6.15 of the SAPA book (default value ok if N-prime is even, but must be replaced if N-prime is odd)
[4] lag-window-function (keyword; #’parzen-lag-window)
==> lag window function of 2 parameters,
tau (the lag) and m (the window parameter)
[5] lambda-factor (keyword; 1.0)
==> lambda, as discussed in Section 6.15 of the SAPA book [6] result (keyword; vector of same length as cepstrum) <== vector to hold I_m
returns
[1] the value m at which I_m is minimized
[2] result, i.e., I_m for m = 0 to N_U
[3] the minimum value of I_m for m = 0 to N_U

Note: see Equation (283b) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: check-orthonormality LIST-OF-VECTORS

given a list of vectors, computes and prints their sum of squares and pairwise dot products, and returns the maximum absolute deviation from 0
of the pairwise dot products

Package

sapa

Source

multitaper.lisp (file)

Function: cholesky! A B &key EPS

given
[1] A (required)
==> vector of length N*(N+1)/2 representing
a two dimensional N by N positive definite matrix
with elements stored columnwise; i.e, elements with indices 0 1 2 3 4 5 ...
correspond to matrix positions
1,1 1,2 2,2 1,3 2,3 3,3 ...
[2] b (required)
<=> right-hand vector on input;
solution X on output
[3] eps (keyword; single-float-epsilon)
number used to test for a computationally singular matrix solves A X = b using the Cholesky decomposition method, and returns
[1] X, the solution vector (stored in b)

Package

sapa

Source

matrix.lisp (file)

Function: circular-shift-sequence A-SEQ &key RESULT

given
[1] a-seq (required)
==> a sequence
[2] result (keyword; vector of same length as a-seq) <== a sequence
returns
[1] a ‘circularly’ left-shifted sequence; i.e., maps x(0), x(1), x(2), ..., x(n-2), x(n-1) to x(n-1), x(0), x(1), ..., x(n-3), x(n-2) —-
Note: result can be the same sequence as result

Package

sapa

Source

utilities.lisp (file)

Function: compare-seqs ONE-SEQ ANOTHER-SEQ

given
[1] one-seq (required)
==> any sequence
[2] another-seq (required)
==> any sequence (must be same length as one-seq) returns
[1] maximum absolute difference between corresponding elements of the two sequences
[2] average absolute difference

Note: useful for comparing results that in theory should be identical

Package

sapa

Source

utilities.lisp (file)

Function: compose-symmetric-filters &rest FILTERS

given any number of symmetric filters (each of odd length and each represented by a vector of coefficients), returns the composite filter
that will produce an output identical to that obtained
by cascading the individual filters

Package

sapa

Source

filtering.lisp (file)

Function: convert-from-db NUM

given
[1] num (required) ==> a number returns
[1] 10^(x/10)

Package

sapa

Source

utilities.lisp (file)

Function: convert-to-db NUM

given
[1] num (required)
==> a number
returns
[1] 10 log_10(num)

Note: num is intended to be a positive number, but this is not checked

Package

sapa

Source

utilities.lisp (file)

Function: copy-vector FROM-VECTOR TO-VECTOR &key START END

given
[1] from-vector (required)
==> a vector (actually, works with any sequence) [2] to-vector (required)
==> a vector (actually, works with any sequence) [3] start (keyword; 0)
==> start index of from-vector to be transferred [4] end (keyword; length of from-vector)
==> 1 + end index of from-vector to be transferred returns
[1] to-vector, with elements start to end - 1 from-vector copied into corresponding
elements 0 to end - start - 1 of to-vector

Note: if to-vector is being created on the spot, might consider using CL’s copy-seq instead.

Package

sapa

Source

utilities.lisp (file)

Function: cosine-data-taper! A-TIME-SERIES &key TAPER-PARAMETER NORMALIZATION RESULT

given
[1] a-time-series (required)
<=> a vector containing a time series;
this vector is modified UNLESS keyword result
is bound to a different vector
[2] taper-parameter (keyword; 1.0, i.e., Hanning data taper) ==> a number >= 0.0 and <= 1.0 that specifies the degree of tapering (parameter p of Equation (209)).
[3] normalization (keyword; :unity)
==> if :unity, taper normalized such that
its sum of squares is equal to unity (Equation (208a)); if :N, taper normalized such that
its sum of squares is equal to the number of points in the time series
[4] result (keyword; a-time-series)
<=> a vector to contain time series multiplied
by cosine data taper
returns
[1] a vector containing the tapered time series
[2] C_h, the variance inflation factor
computed using Equation (251b) in the SAPA book

Package

sapa

Source

tapers.lisp (file)

Function: create-ci-for-amt-sdf-estimate SDF-DB DOFS &key CONFIDENCE-LEVEL

given
[1] sdf-dB (required)
==> vector containing an adaptive multitaper spectral estimate expressed in decibels
[2] dofs (required)
==> vector containing the degrees of freedom associated with the values in sdf-dB
[3] confidence-level (keyword; 0.95)
==> the level of the confidence intervals to be created returns
[1] a vector containing the upper confidence interval [2] a vector containing the lower confidence interval —
Note: see Section 7.4 of the SAPA book

Package

sapa

Source

multitaper.lisp (file)

Function: create-dpss-low-pass-filter FILTER-LENGTH DELTA W &key NYQUIST-FREQUENCY RESULT

given
[1] filter-length (required)
==> an odd positive integer = 2L +1
[2] delta (required)
==> “W” parameter for dpss in user
units (see page 182 of the SAPA book)
[2] W (required)
==> a cutoff frequency greater than 0
and less than the Nyquist frequency
[3] Nyquist-frequency (keyword; 0.5)
==> the Nyquist frequency
[4] result (keyword; vector of length filter-length)
<== vector of length filter-length
into which filter coefficients
are placed (returned by the function)
uses a dpss as convergence factors in least squares approximation to a low-pass filter and
returns
[1] a symmetric low-pass filter of length 2L+1
and a gain of unity at zero frequency;
i.e., result(0) = result(2L)
result(1) = result(2L-1)
etc., and
(sum result) = 1.0

Note: see Section 5.9 of the SAPA book;
(aref result 0) corresponds to element -L of the filter; (aref result L) corresponds to element 0 of the filter; (aref result (* 2 L)) corresponds to element L of the filter

Package

sapa

Source

filtering.lisp (file)

Function: create-least-squares-low-pass-filter FILTER-LENGTH W &key CONVERGENCE-FACTORS NYQUIST-FREQUENCY RESULT

given
[1] filter-length (required)
==> an odd positive integer = 2L +1
[2] W (required)
==> a cutoff frequency greater than 0
and less than the Nyquist frequency
[3] convergence-factors (keyword; nil)
==> a one-argument function that maps
an integer to a convergence factor;
nil is also acceptable, in which case
no convergence factors are used
[4] Nyquist-frequency (keyword; 0.5)
==> the Nyquist frequency
[5] result (keyword; vector of length filter-length)
<== vector of length filter-length
into which filter coefficients
are placed (returned by the function)
uses a least squares approximation to a low-pass filter and returns
[1] a symmetric low-pass filter of length 2L+1
and a gain of unity at zero frequency;
i.e., result(0) = result(2L)
result(1) = result(2L-1)
etc., and
(sum result) = 1.0

Note: see Section 5.8 of the SAPA book;
(aref result 0) corresponds to element -L of the filter; (aref result L) corresponds to element 0 of the filter; (aref result (* 2 L)) corresponds to element L of the filter

Package

sapa

Source

filtering.lisp (file)

Function: cumulative-periodogram TIME-SERIES &key SAMPLING-TIME CENTER-DATA START END CUMULATIVE-PERIODOGRAM-TEST-P SIGNIFICANCE-LEVEL SCRATCH-DFT RETURN-FREQUENCIES-P RESULT-FREQ RESULT

given
[1] time-series (required)
==> a vector containing time series values
[2] sampling-time (keyword; 1.0)
==> the sample time (i.e., delta t)
[3] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, time-series is not centered
[4] start (keyword; 0)
==> start index of vector to be used
[5] end (keyword; length of time-series)
==> 1 + end index of vector to be used
[6] cumulative-periodogram-test-p (keyword; t)
==> if t, returns values associated with
Kolmogorov test statistic
[7] significance-level (keyword; 0.95)
==> level of significance at which Kolmogorov test
is performed
[8] scratch-dft (keyword; vector of size (- end start))
==> scratch vector used for in-place dft calculations
[9] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the cumulative periodogram are computed and returned in result-freq [10] result-freq (keyword; nil or vector of correct length) <== not used if return-frequencies-p nil; otherwise, vector of correct length into which the frequencies associated with the values in result are placed
[11] result (keyword; vector of correct length)
<== vector to hold normalized cumulative periodogram returns
[1] vector with normalized cumulative periodogram
[2] vector with associated frequencies
and – if cumulative-periodogram-test-p is true –
[3] Kolmogorov test statistic
[4] index of maximum deviation
[5] frequency of maximum deviation
[6] quantile of Kolmogorov test statistic (under null hypothesis) [7] either :reject or :fail-to-reject, depending on whether or not we reject or fail to reject the null hypothesis [8] slope of upper and lower lines
[9] intercept of upper line
[10] intercept of lower line

Note: see Section 6.6 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: cumulative-sums THE-SEQ &key START END RESULT

given
[1] the-seq (required)
==> a sequence of numbers
[2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] sequence with cumulative sum
of elements in specified subsequence

Package

sapa

Source

utilities.lisp (file)

Function: daniell-bandwidth->m B_W &key SAMPLING-TIME

given desired smoothing window bandwidth B_W and sampling time, returns
[1] window parameter m required to approximately achieve B_W using the Daneill lag window
[2] actual B_W achieved (in fact, this is always equal to B_W, but we return it anyway for consistency with other lag windows) —
Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: daniell-lag-window TAU M

given the lag tau and window parameter m,
returns the value of the Daniell lag window

Note: see equation between Equations (264a) and (264b) of the SAPA book or Priestley, page 441, Equation (6.2.73)

Package

sapa

Source

nonparametric.lisp (file)

Function: daniell-m->bandwidth M &key SAMPLING-TIME

given window parameter m and sampling time, returns bandwidth B_W for the Daniell smoothing window —
Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: daniell-n-m->degrees-of-freedom N M &key C_H

given sample size N, window parameter m and variance inflation factor C_h, returns equivalent degrees of freedom nu for Daniell lag window

Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: dft! X &key N SAMPLING-TIME

given:
[1] x (required)
<=> a vector of real or complex-valued numbers [2] N (keyword; length of x)
==> number of points in dft
[3] sampling-time (keyword; 1.0)
returns:
[1] x, with contents replaced by
the discrete Fourier transform of x, namely, N-1
X(n) = sampling-time SUM x(t) exp(-i 2 pi n t/N) t=0

Note: see Equation (110a) of the SAPA book

Package

sapa

Source

dft-and-fft.lisp (file)

Function: dft-chirp! COMPLEX-VECTOR &key N

given:
[1] complex-vector (required)
<=> a vector of real or complex-valued numbers [2] N (keyword; length of complex-vector)
==> number of points (must be a power of 2) computes the discrete Fourier transform of complex-vector using a chirp transform algorithm and
returns:
[1] complex-vector, with contents replaced by
the discrete Fourier transform of the input, namely, N-1
X(n) = SUM x(t) exp(-i 2 pi n t/N) t=0

Note: see Equation (110a) of the SAPA book
with the sampling time set to unity and
also Section 3.10 for a discussion on
the chirp transform algorithm

Package

sapa

Source

dft-and-fft.lisp (file)

Function: difference SEQUENCE-OF-NUMBERS &key START END LAG RESULT

given
[1] sequence-of-numbers (required)
==> a sequence of numbers
[2] start (keyword; 0)
==> start index
[3] end (keyword; length of sequence-of-numbers)
==> end index plus one
[4] lag (keyword; 1)
==> lag for differencing
[5] result (keyword; vector of length (- end start lag)) <== results
return
[1] a sequence of length (- end start lag)
with lag-th order difference of sequence
from index start to index end-1

Note: See Newton, 1988, page 31.

Package

sapa

Source

utilities.lisp (file)

Function: digamma X &key X-RECURSION X-SMALL

given
[1] x (required)
==> a positive number
[2] x-recursion (keyword; 8.5)
==> for noninteger x,
if x-small < x < x-recursion,
recursive formula is used
[3] x-small (keyword; 1.0e-5)
==> if x <= x-small,
small x approximation used (default )
returns
[1] value of digamma (psi, derivative of log(gamma)) function at x —
Note: see Abramowitz and Stegun’s equation 6.3.2;
expansion 6.3.18 plus recurrence 6.3.5;
the small x formula is Equation (5) from
Algorithm AS 103 – Psi (Digamma) Function – by J. M. Bernardo in Applied Statistics, Vol. 25, No. 3, 1976, pp. 315–317;
note that better accuracy can be obtained by increasing x-recursion — 10.0 to 100.0 are probably useful values

Package

sapa

Source

basic-math.lisp (file)

Function: direct-spectral-estimate TIME-SERIES &key CENTER-DATA START END N-NONZERO-FREQS RETURN-EST-FOR-0-FREQ-P SAMPLING-TIME SCRATCH-DFT DATA-TAPER DATA-TAPER-PARAMETERS RECENTER-AFTER-TAPERING-P RESTORE-POWER-OPTION-P RETURN-ACVS-P RESULT-ACVS SDF-TRANSFORMATION RESULT-SDF RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] time-series (required)
==> a vector of time series values
[2] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series;
if nil, time-series is not centered
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of time-series)
==> 1 + end index of vector to be used
[5] N-nonzero-freqs (keyword; :half-next-power-of-2)
==> specifies at how many nonzero frequencies
direct spectral estimate is to be computed – choices are: :half-next-power-of-2
==> 1/2 * power of two >= sample size; :next-power-of-2
==> power of two >= sample size; :twice-next-power-of-2
==> 2 * power of two >= sample size; :Fourier
==> just at Fourier frequencies
– or –
any power of 2 >= 1/2 * [power of two >= sample size] [6] return-est-for-0-freq-p (keyword; nil)
==> if t, sdf is computed at zero frequency;
otherwise, it is not computed.
[7] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[8] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[9] data-taper (keyword; nil)
==> nil or a tapering function
[10] data-taper-parameters (keyword)
==> parameters for tapering function (not used
if data-taper is nil)
[11] recenter-after-tapering-p (keyword; t)
==> if t and data-taper is a function,
centers tapered series by subtracting
off its sample mean
[12] restore-power-option-p (keyword; t)
==> if t and data-taper is a function,
normalizes tapered series to have same
sum of squares as before tapering
[13] return-acvs-p (keyword; nil)
==> if t, computes acvs corresponding
to direct spectral estimate
[14] result-acvs (keyword; vector of correct length)
<== vector into which acvs values are placed
(not used if return-acvs-estimate-p is nil)
[15] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[16] result-sdf (keyword; vector of correct length)
<== vector into which direct spectral estimates are placed; it must be exactly of the length dictated
by N-nonzero-freqs and return-est-for-0-freq-p
[17] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the spectral estimate are computed and returned in result-freq
[18] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
(ignored unless return-frequencies-p is true)
[19] result-freq (keyword; nil or vector of correct length)
<== not used if return-frequencies-p nil; otherwise,
vector of length dictated by
N-nonzero-freqs and return-est-for-0-freq-p
into which the frequencies associated with the values in result-sdf are placed
returns
[1] result-sdf, a vector holding
the properly transformed sdf
[2] result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the properly transformed frequencies
associated with values in result-sdf
– or –
nil (if return-frequencies-p is nil)
[3] the length of the vector result-sdf
[4] C_h, the variance inflation factor due to the data taper [5] result-acvs (if return-acvs-p is t),
a vector holding the acvs corresponding
to the direct spectral estimate
– or –
nil (if return-acvs-p is nil)

Note: see Section 6.3 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: dot-product X Y

given
[1] x (required)
==> a sequence of numbers
[2] y (required)
==> a sequence of numbers returns
[1] the dot product of x and y
—-
Note: corresponds to SDOT in LINPACK’s bla

Package

sapa

Source

utilities.lisp (file)

Function: dpss-data-taper! A-TIME-SERIES &key TAPER-PARAMETER NORMALIZATION RESULT

given
[1] a-time-series (required)
<=> a vector containing a time series;
this vector is modified UNLESS keyword result
is bound to a different vector
[2] taper-parameter (keyword; 4.0)
==> a number > 0.0 that specifies NW,
the product of the sample size and
the half-width of the concentration interval
(see SAPA, page 211)
[3] normalization (keyword; :unity)
==> if :unity, taper normalized such that
its sum of squares is equal to unity (Equation (208a)); if :N, taper normalized such that
its sum of squares is equal to the number of points in the time series
[4] result (keyword; a-time-series)
<=> a vector to contain time series multiplied
by cosine data taper
returns
[1] a vector containing the tapered time series
[2] C_h, the variance inflation factor
computed using Equation (251b) in the SAPA book

Package

sapa

Source

tapers.lisp (file)

Function: dpss-tapers-inverse-iteration N NUMBER-OF-TAPERS &key TAPER-PARAMETER PRINT-PROGRESS-P EPS

given
[1] N (required)
the sample size
[2] number-of-tapers (required)
number of orthonormal dpss data tapers
to be computed
[3] taper-parameter (keyword; 4.0)
NW, the duration-half-bandwidth product
(must be such that 0 < NW/N < 1/2)
[4] print-progress-p (keyword; nil)
if t, prints a dot after each eigenvalue
and eigenvector has been computed
[5] eps (keyword; 0.5e-4)
controls accuracy
returns
[1] a list of length number-of-tapers of N dimensional vectors with orthonormal dpss’s of orders 0, 1, ..., number-of-tapers - 1; [2] a vector of length number-of-tapers with the
corresponding eigenvalues

Note: computes the dpss tapers using inverse
iteration (see Section 8.1 of the SAPA book)

Package

sapa

Source

multitaper.lisp (file)

Function: dpss-tapers-thomson-approx N NUMBER-OF-TAPERS &key TAPER-PARAMETER PRINT-PROGRESS-P COMPUTE-TRUE-EIGENVALUES-P ABSCISSAS WEIGHTS

given
[1] N (required)
the sample size
[2] number-of-tapers (required)
number of orthonormal dpss data tapers
to be computed
[3] taper-parameter (keyword; 4.0)
NW, the duration-half-bandwidth product
(must be such that 0 < NW/N < 1/2)
[4] print-progress-p (keyword; nil)
if t, prints a dot after each eigenvalue
and eigenvector has been computed
[5] compute-true-eigenvalues-p (keyword; nil)
if t, returns eigenvalues for eigenproblem
of Equation (378) of the SAPA book;
if nil, returns nil
[6] abscissas (keyword; *abscissas-32-point*)
a vector of abscissas points used
in Gauss-Legendre quadrature
[7] weights (keyword; *abscissas-32-point*)
a vector of weights used
in Gauss-Legendre quadrature
returns
[1] a list of length number-of-tapers of N dimensional vectors with orthonormal dpss’s of orders 0, 1, ..., number-of-tapers - 1; [2] a vector of length number-of-tapers with
eigenvalues if compute-true-eigenvalues-p is t;
nil if if compute-true-eigenvalues-p is nil

Note: computes the dpss tapers using Thomson’s numerical
integration scheme (see Section 8.2 of the SAPA book)

Package

sapa

Source

multitaper.lisp (file)

Function: dpss-tapers-tri-diag N NUMBER-OF-TAPERS &key TAPER-PARAMETER PRINT-PROGRESS-P COMPUTE-TRUE-EIGENVALUES-P

given
[1] N (required)
the sample size
[2] number-of-tapers (required)
number of orthonormal dpss data tapers
to be computed
[3] taper-parameter (keyword; 4.0)
NW, the duration-half-bandwidth product
(must be such that 0 < NW/N < 1/2)
[4] print-progress-p (keyword; nil)
if t, prints a dot after each eigenvalue
and eigenvector has been computed
[5] compute-true-eigenvalues-p (keyword; nil)
if t, returns eigenvalues for eigenproblem
of Equation (378) of the SAPA book;
if nil, returns eigenvalues for tridiagonal
formulation
returns
[1] a list of length number-of-tapers of N dimensional vectors with orthonormal dpss’s of orders 0, 1, ..., number-of-tapers - 1; [2] a vector of length number-of-tapers with
eigenvalues as specified by compute-true-eigenvalues-p

Note: computes the dpss tapers using the tridiagonal
formulation (see Section 8.3 of the SAPA book)

Package

sapa

Source

multitaper.lisp (file)

Function: durbin-watson-test-statistic RESIDUALS

given a set of residuals in a seqeunce, returns the Durbin-Watson test statistic

Package

sapa

Source

basic-statistics.lisp (file)

Function: eigenspectra->adaptive-multitaper-spectral-estimate LIST-OF-EIGENSPECTRA EIGENVALUES VARIANCE-OF-TIME-SERIES &key SAMPLING-TIME N-EIGENSPECTRA MAXIMUM-NUMBER-OF-ITERATIONS RESULT-DOF SDF-TRANSFORMATION RESULT-SDF

given
[1] list-of-eigenspectra (required)
==> list of eigenspectra (such as optionally returned
by multitaper-spectral-estimate); each eigenspectrum
is assumed to be untransformed (e.g., not expressed
in dB)
[2] eigenvalues (required)
==> vector of eigenvalues corresponding to the dpss’s
used to create the eigenspectra (the length of eigenvalues should be at least as large as the length specified
by N-eigenspectra)
[3] variance-of-time-series (required)
==> variance of time series
from which eigenspectra were computed
[4] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[5] N-eigenspectra (keyword; length of list-of-eigenspectra)
==> number of eigenspectra to be used (must be less than
or equal to the length of list-of-eigenspectra)
[6] maximum-number-of-iterations (keyword; 100)
==> maximum number of iterations
[7] result-dof (keyword; vector of correct length)
<== vector into which degrees of freedom for each value
in the adaptive multitaper spectral estimate is placed;
it must be exactly the same length as each of the vectors
in list-of-eigenspectra
[8] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[9] result-sdf (keyword; vector of correct length)
<== vector into which adaptive multitaper spectral estimate is placed; it must be exactly the same length as each of the vectors
in list-of-eigenspectra
returns
[1] result-sdf, a vector holding
the properly transformed adaptive multitaper spectral estimate
[2] result-dof, a vector holding corresponding degrees of freedom
[3] the maximum number of iterations required to reach convergence
for all of the values in result-sdf

Note: see Section 7.4 of the SAPA book

Package

sapa

Source

multitaper.lisp (file)

Function: eigenspectra->multitaper-spectral-estimate LIST-OF-EIGENSPECTRA &key N-EIGENSPECTRA SDF-TRANSFORMATION RESULT-SDF

given
[1] list-of-eigenspectra (required)
==> list of eigenspectra (such as optionally returned
by multitaper-spectral-estimate); each eigenspectrum is assumed to be untransformed (e.g., not expressed in dB) and represented by a vector
[2] N-eigenspectra (keyword; length of list-of-eigenspectra) ==> number of eigenspectra to be used (must be less than or equal to the length of list-of-eigenspectra)
[3] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[4] result-sdf (keyword; vector of correct length)
<== vector into which multitaper spectral estimate is placed; it must be exactly the same length as each of the vectors in list-of-eigenspectra
returns
[1] result-sdf, a vector holding
the properly transformed multitaper spectral estimate

Note: see Section 7.1 of the SAPA book

Package

sapa

Source

multitaper.lisp (file)

Function: equivalent-degrees-of-freedom LAG-WINDOW-FUNCTION MAX-LAG &key SAMPLING-TIME SAMPLE-SIZE C_H

given a lag window function, a maximum lag, the sampling time, the sample size and the variance inflation factor C_h, returns the corresponding equivalent degrees of freedom —
Note: see Equation (255a) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: euclidean-norm X

given
[1] x (required)
==> a sequence of numbers returns
[1] Euclidean norm of x
—-
Note: corresponds to LINPACK’s SNRM2, but this is POOR implementation!

Package

sapa

Source

utilities.lisp (file)

Function: evaluate-polynomial POLYNOMIAL Z &key DEGREE-OF-POLYNOMIAL NUMBER-OF-DERIVATIVES COMPLEX-VALUES BOUNDS-TO-BE-COMPUTED BOUNDS

given
[1] polynomial (required)
==> sequence of length n+1 with real or
complex-valued numbers giving the n+1
coefficients of a polynomial of nth order;
(elt polynomial i) = coefficient of z^(n-i)
[2] z (required)
==> complex point at which the polynomial
to be evaluated
[3] degree-of-polynomial (keyword; (1- (length polynomial)))
==> degree of polynomial
[4] number-of-derivatives (keyword; 0)
==> number of derivatives to be evaluated
[5] complex-values (keyword; array of length (1+ number-of-derivatives)) <== sequence with values of polynomial
and derivatives
[6] bounds-to-be-computed (keyword; nil)
==> if t, error bounds are computed
for values in complex-values
[7] bounds (keyword; array of length (1+ number-of-derivatives))
<== sequence with error bounds
returns
[1] the sequence complex-values containing the value
of the polynomial and its derivatives
[2] bounds, a sequence containing optional error bounds

Note: this is a Lisp version of cmlib routine cpevl;
d1 was specified in cpevl as (expt 2 (- 1 (i1mach 11))),
where (i1mach 11) ==> THE NUMBER OF BASE-2 DIGITS (SINGLE PRECISION).
I have taken this to be equivalent to machine epsilon.
If this is in fact NOT the case, then the optional error bounds
might not be computed correctly.

Package

sapa

Source

basic-math.lisp (file)

Function: exponential-smoothing TIME-SERIES ALPHA &key INITIAL-PREDICTION RETURN-SMOOTHED-VALUES-P N-PREDICTIONS RESULT-SMOOTHED RESULT-PREDICTIONS

given
[1] time-series (required)
==> a sequence of numbers
[2] alpha (required)
==> parameter controlling the degree of exponential smoothing (usually 0 < alpha < 1)
[3] initial-prediction (keyword; first element of time-series)
==> to get the smoother going, we need a “prediction” for
the first element in the sequence time-series – two
common hacks are the first element itself (the default)
or 0 (if the time series has a zero sample mean)
[4] return-smoothed-values-p (keyword; t)
==> if t, returns smoothed (i.e., filtered) time series
[5] n-predictions (keyword; 0)
==> number of predictions desired
[6] result-smoothed (keyword; vector of length of time-series or nil) <== a sequence to hold smoothed (filtered) time series – used only if return-smoothed-values-p is true
[7] result-predictions (keyword; vector of length n-predictions or nil) <== a sequence to hold predicted values of the time series – used only if n-predictions is positive
returns
[1] sum-of-squares of prediction errors
[2] either one step ahead prediction (if n-predictions is 0)
or vector of length n-predictions if n-predictions > 0)
[3] vector with smoothed values
(nil if return-smoothed-values-p is true)

Note: see Section 7.3 of “Time Series: A Biostatistical Introduction” by Diggle, 1990

Package

sapa

Source

filtering.lisp (file)

Function: factorial K

given an integer k, returns k!

Package

sapa

Source

basic-math.lisp (file)

Function: fast-forward-backward-ls TIME-SERIES P &key START END CENTER-DATA AR-COEFFS PSEUDO-REFLECTION-COEFFS

given
[1] time-series (required)
==> a vector containing a real-valued or complex-valued time series x_t
[2] p (required)
==> autoregressive model order;
p should be an integer > 0 and < end - start
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of vector to be used
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, the effect of this function is to return
a copy of the relevant portion of time-series
[6] AR-coeffs (keyword; a vector of length p)
<== estimates of AR coefficients phi_{1,p}, ..., phi_{p,p} [7] pseudo-reflection-coeffs (keyword; a vector of length p) <== sequence of reflection coefficients computed stepwise by the algorithm, but these do not correspond to the estimated phi_{k,p} (even if the estimated AR model is stationary)
uses the forward/backward least squares method
to estimate the phi’s in the model
x_t = phi_{1,p} x_{t-1} + ... + phi_{p,p} x_{t-p} + e_t and returns
[1] AR-coeffs, a vector containing phi_{1,p}, ..., phi_{p,p} [2] estimate of the innovations variance, i.e.,
the variance of the e_t’s
[3] pseudo-reflection-coeffs

Note: see Section 9.7 of the SAPA book;
this function is an adaptation of
the Fortran routine modcovar, pp. 258-60,
“Digital Spectral Analysis with Applications”
by Marple, 1987

Package

sapa

Source

parametric.lisp (file)

Function: fft! COMPLEX-VECTOR &key N

given:
[1] complex-vector (required)
<=> a vector of real or complex-valued numbers [2] N (keyword; length of complex-vector)
==> number of points (must be a power of 2) computes the discrete Fourier transform of complex-vector using a fast Fourier transform algorithm and
returns:
[1] complex-vector, with contents replaced by
the discrete Fourier transform of the input, namely, N-1
X(n) = SUM x(t) exp(-i 2 pi n t/N) t=0

Note: see Equation (110a) of the SAPA book
with the sampling time set to unity

Package

sapa

Source

dft-and-fft.lisp (file)

Function: filter-time-series TIME-SERIES THE-FILTER &key START END TECHNIQUE RESULT

given
[1] time-series (required)
==> a vector containing a time series
x_0, x_1, ..., x_{N-1}
[2] the-filter (required)
==> a vector containing the filter coefficients g_0, g_1, ..., x_{K-1}
[3] start (keyword; 0)
==> start index of time-series to be used
[4] end (keyword; length of time-series)
==> 1 + end index of time-series to be used
[5] technique (keyword; :fastest)
==> if :fastest, tries to pick fastest method; if :fft, uses fft-based method;
if :direct, uses direct method
[6] result (keyword; vector of appropriate length) <== vector to contain filtered time series K-1
y_t = SUM g_k x_{t+K-1-k}, t = 0, ..., N-K+1 k=0
returns
[1] result, a vector containing the filtered time series [2] the number of values in the filtered time series —
Note: result can be the same as time-series

Package

sapa

Source

filtering.lisp (file)

Function: filter-time-series-direct TIME-SERIES THE-FILTER &key START END RESULT

given
[1] time-series (required)
==> a vector containing a time series
x_0, x_1, ..., x_{N-1}
[2] the-filter (required)
==> a vector containing the filter coefficients g_0, g_1, ..., x_{K-1}
[3] start (keyword; 0)
==> start index of time-series to be used
[4] end (keyword; length of time-series)
==> 1 + end index of time-series to be used
[5] result (keyword; vector of appropriate length) <== vector to contain filtered time series K-1
y_t = SUM g_k x_{t+K-1-k}, t = 0, ..., N-K+1 k=0
returns
[1] result, a vector containing the filtered time series [2] the number of values in the filtered time series —
Note: result can be the same as time-series

Package

sapa

Source

filtering.lisp (file)

Function: filter-time-series-fft TIME-SERIES THE-FILTER &key START END FFT-SIZE VERBOSE-P RESULT

given
[1] time-series (required)
==> a vector containing a time series
x_0, x_1, ..., x_{N-1}
[2] the-filter (required)
==> a vector containing the filter coefficients
g_0, g_1, ..., x_{K-1}
[3] start (keyword; 0)
==> start index of time-series to be used
[4] end (keyword; length of time-series)
==> 1 + end index of time-series to be used
[5] fft-size (keyword; 4 * power of 2 that is ceiling for filter length) ==> size of fft’s to be used (must be a power of 2)
[6] verbose-p (keyword; nil)
==> if t, prints line after each block of data is processed;
if nil, prints nothing
[7] result (keyword; vector of appropriate length)
<== vector to contain filtered time series
K-1
y_t = SUM g_k x_{t+K-1-k}, t = 0, ..., N-K+1 k=0
returns
[1] result, a vector containing the filtered time series
[2] the number of values in the filtered time series

Note: result can be the same as time-series

Package

sapa

Source

filtering.lisp (file)

Function: find-peak-of-ar-sdf-using-quadratic-approx F_1 F_2 F_3 AR-COEFFS &key SAMPLING-TIME DB-TOLERANCE

given
[1] f_1 (required)
==> frequency f_1 such that f_1 < f_2 and S(f_1) < S(f_2),
where S(.) is the sdf associated with AR-coeffs
[2] f_2 (required)
==> middle frequency
[3] f_3 (required)
==> frequency f_3 such that f_3 > f_2 and S(f_3) < S(f_2)
[4] AR-coeffs (required)
==> vector with real-valued AR coefficients phi_{j,p}
for an AR(p) model of order p:
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2}
+ ... + phi_{p,p} * x_{t-p} + e_t
[5] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[6] dB-tolerance (keyword; 0.1)
==> convergence criterion
returns
[1] estimate of frequency of peak/valley in sdf

Note: for details on this method, see pages 20-21 of Adby and Dempster, “Introduction to Optimization Methods”; note in particular that we search the inverse of the AR portion of the spectrum instead of the spectrum itself in the belief that the quadratic approximation is better with this reformulation

Package

sapa

Source

parametric.lisp (file)

Function: find-peak-or-valley-of-sdf-using-bisection+newton-raphson F-LEFT F-RIGHT ERSATZ-ACVS &key SAMPLING-TIME N ACCURACY MAXIMUM-NUMBER-OF-ITERATIONS

given
[1] f-left (required)
==> left bracket for frequency of peak/valley
[2] f-right (required)
==> right bracket for frequency of peak/valley
[3] ersatz-acvs (required)
==> vector of length N with acvs (or acs) s_0 to s_{N-1} corresponding to sdf (only elements 1 to N-1 are used) [4] sampling-time (keyword; 1.0)
==> positive number
[5] N (keyword; length of ersatz-acvs)
==> positive integer
[6] accuracy (keyword; 10.0 * single-float-epsilon)
==> passed to bisection-with-Newton-Raphson
[7] maximum-number-of-iterations (keyword; 20)
==> passed to bisection-with-Newton-Raphson
returns
[1] estimate of frequency of peak/valley in sdf
[2] number of iterations required

Note: searches for peak using a combination of
bisection and Newton-Raphson;
see pages 479–80 and 524–5 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: fisher-g-statistic TIME-SERIES &key CENTER-DATA START END ALPHA

given
[1] time-series (required)
==> a vector of time series values
[2] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, time-series is not centered
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of time-series)
==> 1 + end index of vector to be used
[5] alpha (keyword; 0.05)
==> critical level at which Fisher’s g test
is performed
returns
[1] Fisher’s g statistic
[2] approximation to critical level of Fisher’s g test from Equation (491c)
[3] either :reject or :fail-to-reject, depending on whether or not we reject or fail to reject the null hypothesis of white noise

Note: see Section 10.9 of the SAPA book

Package

sapa

Source

harmonic.lisp (file)

Function: forward-backward-ls TIME-SERIES P &key START END CENTER-DATA AR-COEFFS

given
[1] time-series (required)
==> a vector containing a real-valued or complex-valued time series x_t
[2] p (required)
==> autoregressive model order;
p should be an integer > 0 and < end - start
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of vector to be used
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, the effect of this function is to return
a copy of the relevant portion of time-series
[6] AR-coeffs (keyword; a vector of length p)
<== estimates of AR coefficients phi_{1,p}, ..., phi_{p,p} uses the forward/backward least squares method
to estimate the phi’s in the model
x_t = phi_{1,p} x_{t-1} + ... + phi_{p,p} x_{t-p} + e_t and returns
[1] AR-coeffs, a vector containing phi_{1,p}, ..., phi_{p,p} [2] estimate of the innovations variance, i.e.,
the variance of the e_t’s

Note: see Section 9.7 of the SAPA book;
this function is an adaptation of
the Fortran routine covmcov, pp. 262-4,
“Modern Spectrum Estimation: Theory and Application” by Kay, 1988

Package

sapa

Source

parametric.lisp (file)

Function: forward-ls TIME-SERIES P &key START END CENTER-DATA AR-COEFFS

given
[1] time-series (required)
==> a vector containing a real-valued or complex-valued time series x_t
[2] p (required)
==> autoregressive model order;
p should be an integer > 0 and < end - start
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of vector to be used
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, the effect of this function is to return
a copy of the relevant portion of time-series
[6] AR-coeffs (keyword; a vector of length p)
<== estimates of AR coefficients phi_{1,p}, ..., phi_{p,p} uses the forward least squares method
to estimate the phi’s in the model
x_t = phi_{1,p} x_{t-1} + ... + phi_{p,p} x_{t-p} + e_t and returns
[1] AR-coeffs, a vector containing phi_{1,p}, ..., phi_{p,p} [2] estimate of the innovations variance, i.e.,
the variance of the e_t’s

Note: see Section 9.7 of the SAPA book;
this function is an adaptation of
the Fortran routine covmcov, pp. 262-4,
“Modern Spectrum Estimation: Theory and Application” by Kay, 1988

Package

sapa

Source

parametric.lisp (file)

Function: gauss-legendre-quadrature LOWER-LIMIT UPPER-LIMIT N

given
[1] lower-limit (required)
==> lower limit of integration
[2] upper-limit (required)
==> upper limit of integration
[3] N (required)
==> number of points to be computed
in Gauss-Legendre quadrature returns
[1] an N-dimensional vector of abscissas points [2] an N-dimensional vector of weights

Note: this function is based on gauleg, Section 4.5, Numerical Recipes, Second Edition

Package

sapa

Source

basic-math.lisp (file)

Function: generate-ar-time-series COEFFS VARIANCE SAMPLE-SIZE &key PROCESS-VARIANCE-P LIST-OF-LOWER-ORDER-PHI LIST-OF-LOWER-ORDER-PEV RESULT

given
[1] coeffs (required)
==> sequence of length p with AR coefficients:
x_t = coeffs_0*x_{t-1} + coeffs_1*x_{t-2}
+ ... + coeffs_{p-1}*x_{t-p} + e_t
(see Equation (392a) in the SAPA book;
the coefficients can be real or complex-valued)
[2] variance (required)
==> process variance or innovations variance
(see keyword process-variance-p)
[3] sample-size (required)
==> length of generated time series
[4] process-variance-p (keyword; t)
==> if t, variance is taken to be process variance
if nil, variance is taken to be innovations variance
[5] list-of-lower-order-phi (keyword; nil)
==> to bypass call to step-down-Levinson-Durbin-recursions (useful for multiple realizations)
[6] list-of-lower-order-pev (keyword; nil)
==> to bypass call to step-down-Levinson-Durbin-recursions
[7] result (keyword; vector of length sample-size)
<== vector with simulated series
generates realization of zero mean normally distributed AR(p) process and returns
[1] result, vector of length sample-size with realization
[2] list-of-lower-order-phi (can be used on subsequent calls
to this function to bypass call to step-down-Levinson-Durbin-recursions)
[3] list-of-lower-order-pev (can be also used on subsequent calls) —
Note: this function generates the proper stationary initial conditions

Package

sapa

Source

random.lisp (file)

Function: generate-backward-innovations TIME-SERIES AR-COEFFS &key START END CENTER-DATA RESULT

given
[1] time-series (required)
==> a vector containing a real-valued
time series x_t
[2] AR-coeffs (required)
==> vector with real-valued AR coefficients phi_{j,p} for an AR(p) model of order p:
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2} + ... + phi_{p,p} * x_{t-p} + e_t
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of vector to be used
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series (the vector time-series is not altered)
[6] result (keyword; vector of appropriate length)
<== vector to contain backward innovations p
b_t = x_t - SUM phi_{j,p} x_{t+j}, t = 1, ..., N-p j=1
returns
[1] result, i.e., the backward innovations

Package

sapa

Source

parametric.lisp (file)

Function: generate-forward-innovations TIME-SERIES AR-COEFFS &key START END CENTER-DATA RESULT

given
[1] time-series (required)
==> a vector containing a real-valued
time series x_t
[2] AR-coeffs (required)
==> vector with real-valued AR coefficients phi_{j,p}
for an AR(p) model of order p:
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2}
+ ... + phi_{p,p} * x_{t-p} + e_t
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of vector to be used
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series (the vector time-series is not altered)
[6] result (keyword; vector of appropriate length)
<== vector to contain forward innovations p
f_t = x_{t+p} - SUM phi_{j,p} x_{t-j}, t = 1, ..., N - p j=1
returns
[1] result, i.e., the fprward innovations

Package

sapa

Source

parametric.lisp (file)

Function: generate-ma-time-series COEFFS VARIANCE SAMPLE-SIZE &key PROCESS-VARIANCE-P RESULT

given
[1] coeffs (required)
==> sequence of length q with MA coefficients:
x_t = e_t - coeffs_0*e_{t-1}
- coeffs_1*e_{t-2}
- ... - coeffs_{q-1}*e_{t-q}
(see Equation (43a) in the SAPA book)
[2] variance (required)
==> process variance or innovations variance
(see keyword process-variance-p)
[3] sample-size (required)
==> length of generated time series
[4] process-variance-p (keyword; t)
==> if t, variance is taken to be process variance
if nil, variance is taken to be innovations variance
[5] result (keyword; vector of length sample-size)
<== vector with simulated series
generates realization of zero mean normally distributed MA(q) process and returns
[1] vector of length sample-size with realization

Package

sapa

Source

random.lisp (file)

Function: generate-white-noise N &key DISTRIBUTION RESULT

given
[1] n (required)
==> a sample size
[2] distribution (keyword; :normal)
==> either a keyword or a function with no arguments that returns a random deviate from a particular distribution. Choices are
:binary :cauchy :chi-square-2 :double-exponential :exponential
:extreme-value :Gaussian (same as :normal) :logistic :lognormal :normal :uniform
[3] result (keyword; vector of length n)
<== a sequence in which results are to be stored return
[1] result, containing n samples from a white noise process with a distribution specified by the keyword distribution

Package

sapa

Source

random.lisp (file)

Function: grenander-smoothing-window-bandwidth LAG-WINDOW-FUNCTION MAX-LAG &key SAMPLING-TIME

given a lag window function, a maximum lag and the sampling time, returns Grenander’s measure of smoothing window bandwidth

Note: see Equations (241c) and (241b) of the SAPA book; unfortunately, because of the square root operation, this measure can be complex-valued for certain lag windows

Package

sapa

Source

nonparametric.lisp (file)

Function: hanning-data-taper! A-TIME-SERIES &key TAPER-PARAMETER NORMALIZATION RESULT

calls cosine-data-taper! with taper-parameter set to 1.0

Package

sapa

Source

tapers.lisp (file)

Function: hermitian-transpose A-MATRIX &key RESULT

given
[1] A (required)
==> a 2d matrix
[2] result (keyword; new 2d array of appropriate size)
<== a 2d matrix to contain Hermitian transpose of a-matrix returns
[1] Hermitian transpose of a-matrix (placed in result)

Package

sapa

Source

matrix.lisp (file)

Function: histogram SEQUENCE-OF-DEVIATES &key NUMBER-OF-BINS LEFT-OF-FIRST-BIN RIGHT-OF-LAST-BIN SCALE-AS-DENSITY-P RESULT

given
[1] sequence-of-deviates (required)
==> a sequence of real-valued numbers
[2] number-of-bins (keyword; 10)
==> number of bins in histogram
[3] left-of-first-bin (keyword; min of sequence-of-deviates)
==> leftmost value of first bin
[4] right-of-last-bin (keyword; max of sequence-of-deviates)
==> rightmost value of last bin
[5] scale-as-density-p (keyword; t)
==> if t, histogram is scaled as a density;
otherwise, cell counts are returned
[6] result (keyword; vector of size number-of-bins)
<== vector to hold the histogram
returns
[1] the vector result, which contains the values for the histogram for sequence-of-deviates (one value for each bin); note that,
if a bin has boundaries a and b, all points x in sequence-of-deviates for which a<=x<b are counted as being in that bin
EXCEPT for the last bin, where the rule is a<=x<=b.
[2] maximum value in the histogram (i.e., result)
[3] leftmost value of first bin
[4] bin-width of bins
[5] the number of unbinned elements in sequence-of-deviates
less than left-of-first-bin
[6] the number of unbinned elements in sequence-of-deviates
greater than right-of-last-bin

Note: the value in (svref result 0) is the histogram value
for the interval [leftmost value of first bin,
leftmost value of first bin + bin-width of bins); the value in (svref result 1) is the histogram value
for the interval [leftmost value of first bin + bin-width of bins, leftmost value of first bin + 2*bin-width of bins); etc.

Package

sapa

Source

basic-statistics.lisp (file)

Function: huber-weight-function X &key PARAMETER

given
[1] x (required)
==> value at which to evaluate Huber’s weight function [2] parameter (keyword; 1.5)
==> tuning parameter
returns
[1] value of Huber’s weight function at x

Package

sapa

Source

basic-statistics.lisp (file)

Function: ideal-band-pass-filter-irs K W-LOW W-HIGH

given
[1] k (required)
==> index of member of impulse response sequence (irs) to be calculated (must be an integer)
[2] W-low (required)
==> the low frequency cutoff (in standardized units) [3] W-high (required)
==> the high frequency cutoff (in standardized units so that 0 <= W-low < W-high <= 0.5, the assumed Nyquist frequency).
returns
[1] k-th member of the impulse response sequence
for an ideal band-pass filter

Package

sapa

Source

filtering.lisp (file)

Function: ideal-high-pass-filter-irs K W

given
[1] k (required)
==> index of member of impulse response sequence (irs) to be calculated (must be an integer)
[2] W (required)
==> the cutoff frequency, standardized such that
0 < W < 0.5 = Nyquist frequency
returns
[1] kth member of the impulse response sequence
for an ideal low-pass filter with cutoff frequency W

Package

sapa

Source

filtering.lisp (file)

Function: ideal-low-pass-filter-irs K W

given
[1] k (required)
==> index of member of impulse response sequence (irs) to be calculated (must be an integer)
[2] W (required)
==> the cutoff frequency, standardized such that
0 < W < 0.5 = Nyquist frequency
returns
[1] kth member of the impulse response sequence
for an ideal low-pass filter with cutoff frequency W —
Note: see Section 5.8 of the SAPA book

Package

sapa

Source

filtering.lisp (file)

Function: integrate-sdf SDF FREQS &key FIDDLE-FACTOR RETURN-INTEGRATED-SDF-P RESULT

given
[1] sdf (required)
==> vector with sdf for a real or complex-valued process computed over a grid of frequencies (the grid
need not be uniform) – note that the sdf values
must be untransformed (e.g., not in decibels)
[2] freqs (required)
==> vector with frequencies over which
sdf has been computed
(must be same size as vector with sdf values)
[3] fiddle-factor (keyword; 2.0)
==> values returned are all multiplied by this factor;
the default of 2 is useful for real-valued processes since these have symmetric two-sided sdf’s.
[4] return-integrated-sdf-p (keyword; nil)
==> if t, integrated sdf as a function of frequency
is computed and returned in result
[5] result (keyword; vector of length sdf)
<== vector with integrated sdf (if return-integrated-sdf-p is t) or nil (if return-integrated-sdf-p is nil)
returns
[1] the integral of the sdf * fiddle-factor
[2] result, i.e., the integrated sdf
if return-integrated-sdf-p is t

Package

sapa

Source

parametric.lisp (file)

Function: interquartile-range THE-SEQ &key START END THE-SEQ-IS-ORDERED-P

given
[1] the-seq (required)
==> a sequence of real-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used [4] the-seq-is-ordered-p (keyword; nil) ==> if t, the-seq is assumed to
be sorted from smallest to largest value; if nil, the-seq will be sorted returns
[1] interquartile range; i.e,
0.75 quantile minus 0.25 quantile

Package

sapa

Source

basic-statistics.lisp (file)

Function: inverse-dft! X &key N SAMPLING-TIME

given:
[1] X (required)
<=> a vector of real or complex-valued numbers
[2] N (keyword; length of )
==> number of points in inverse dft
[3] sampling-time (keyword; 1.0)
returns:
[1] X, with contents replaced by
the inverse discrete Fourier transform of X, namely, N-1
x(t) = (N sampling-time)^{-1} SUM X(n) exp(i 2 pi n t/N) n=0

Note: see Equation (111a) of the SAPA book

Package

sapa

Source

dft-and-fft.lisp (file)

Function: inverse-fft! COMPLEX-VECTOR &key N

given:
[1] complex-vector (required)
<=> a vector of real or complex-valued numbers
[2] N (keyword; length of )
==> number of points in inverse dft
(must be a power of 2)
computes the inverse discrete Fourier transform of complex-vector using a fast Fourier transform algorithm and
returns:
[1] complex-vector, with contents replaced by
the inverse discrete Fourier transform of
the input X(n), namely,
N-1
x(t) = 1/N SUM X(n) exp(i 2 pi n t/N) n=0

Note: see Equation (111a) of the SAPA book
with the sampling time set to unity

Package

sapa

Source

dft-and-fft.lisp (file)

Function: iota START END &key TYPE FLOAT-P SKIP RESULT

given
[1] start (required)
==> an integer
[2] end (required)
==> an integer >= start
[3] type (keyword; ’vector)
==> type of sequence desired
[4] float-p (keyword; nil)
==> if true, sequence consists of floats
[5] skip (keyword; 1)
==> desired increment between integers in sequence [6] result (keyword; sequence of length (1+ (- start end))) ==> storage space for result
returns
[1] a sequence of length (1+ (/ (- end start) skip)) with numbers start, start + skip, ..., end - skip, end (these are stored in whatever result points to)

Package

sapa

Source

utilities.lisp (file)

Function: jenkins-smoothing-window-bandwidth LAG-WINDOW-FUNCTION MAX-LAG &key SAMPLING-TIME

given a lag window function, a maximum lag and the sampling time, returns Jenkins’ measure of smoothing window bandwidth

Note: see Equation (242c) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: kernel-pdf-estimation A-SEQ START-X INCREMENT-X N-PDF &key WINDOW-WIDTH RESULT-PDF RESULT-X

given
[1] a-seq (required)
==> a sequence of real-valued numbers
[2] start-x (required)
==> first point at which pdf is
to be estimated
[3] increment-x (required)
==> increment between points at which pdf is
to be estimated (i.e., second point is
at start-x + increment-x, third point is
at start-x + 2*increment-x, etc)
[4] n-pdf (required)
==> number of points at which pdf is
to be estimated
[5] window-width (keyword; Silverman’s formula)
==> window width of kernel pdf estimator
[6] result-pdf (keyword; vector of length n-pdf)
<== vector to hold pdf estimate
[7] result-x (keyword; vector of length n-pdf)
<== vector to hold points at which
pdf was estimated
computes a pdf estimate using the normal (Gaussian) kernel and returns
[1] the pdf estimate (in result-pdf)
[2] the points associated with the pdf estimates (in result-x) [3] the window width

Package

sapa

Source

basic-statistics.lisp (file)

Function: lag-window-spectral-estimate ACVS LAG-WINDOW-FUNCTION &key MAX-LAG N-TS N-NONZERO-FREQS RETURN-EST-FOR-0-FREQ-P SAMPLING-TIME SCRATCH-DFT C_H SDF-TRANSFORMATION RESULT-SDF RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] acvs (required)
==> vector containing autocovariance sequence
[2] lag-window-function (required)
==> function of a single variable that computes the value of the lag window for a given lag
[3] max-lag (keyword; (1- (length acvs)))
==> maximum lag in acvs to be used
[4] N-ts (keyword; length of acvs)
==> length of the time series from which acvs was constructed; this is needed to compute equivalent degrees of freedom [5] N-nonzero-freqs (keyword; :half-next-power-of-2)
==> specifies at how many nonzero frequencies
direct spectral estimate is to be computed – choices are: :half-next-power-of-2
==> 1/2 * power of two >= sample size; :next-power-of-2
==> power of two >= sample size; :twice-next-power-of-2
==> 2 * power of two >= sample size; :Fourier
==> just at Fourier frequencies
– or –
any power of 2 >= 1/2 * [power of two >= sample size] [6] return-est-for-0-freq-p (keyword; nil)
==> if t, sdf is computed at zero frequency;
otherwise, it is not computed.
[7] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[8] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[9] C_h (keyword; 1.0)
==> variance inflation factor due to tapering
[10] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[11] result-sdf (keyword; vector of correct length)
<== vector into which lag window spectral estimates are placed; it must be exactly of the length dictated
by N-nonzero-freqs and return-est-for-0-freq-p
[12] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the spectral estimate are computed and returned in result-freq
[13] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
(ignored unless return-frequencies-p is true)
[14] result-freq (keyword; nil or vector of correct length)
<== not used if return-frequencies-p nil; otherwise,
vector of length dictated by
N-nonzero-freqs and return-est-for-0-freq-p
into which the frequencies associated with the values in result-sdf are placed
returns
[1] result-sdf, a vector holding
the properly transformed sdf
[2] result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the properly transformed frequencies
associated with values in result-sdf
– or –
nil (if return-frequencies-p is nil)
[3] the length of the vector result-sdf
[4] the equivalent degrees of freedom
[5] the smoothing window bandwidth

Note: see Section 6.7 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: linear-interpolation! A-SEQUENCE &key INTERPOLATION-PREDICATE

given
[1] a-sequence (required)
<=> a sequence of numbers
[2] interpolation-predicate (keyword; #’zerop) ==> a unitary predicate which, when true, indicates that a value in a-sequence
is to be replaced by a linear interpolation returns
[1] a-sequence, modified with linear interpolates over specified values

Package

sapa

Source

utilities.lisp (file)

Function: linearized-upper-trangular->2d-matrix A &key RESULT

given
[1] A (required)
==> a vector with an upper triangular matrix stored in linearized form
[2] result (keyword; new 2d array of appropriate size) <== a 2d hermitian matrix filled according
to contents of A
converts linearized form A into 2d hermitian array and returns
[1] result, a 2d hermitian matrix

Package

sapa

Source

matrix.lisp (file)

Function: log-of-gamma XX

given xx (a real or complex valued number whose real part is greater than 0),
returns the log (base e) of gamma(xx)

Note: based upon the discussion in Section 6.1, Numerical Recipes, Second Edition

Package

sapa

Source

basic-math.lisp (file)

Function: log10 NUM

given
[1] num (required)
==> a number
returns
[1] log_10(num)

Note: shorthand for (log num 10)

Package

sapa

Source

utilities.lisp (file)

Function: lower-triangular-solve! A B &key N

given
[1] A (required)
==> lower n by n triangular matrix
(note: upper superdiagonal part of this matrix is ignored) [2] b (required)
<=> on input, the right-hand side vector;
on output, the solution X to A X = b
[3] n (keyword; length of b)
==> order of matrix A
returns
[4] X, the solution to A X = b, where X is the same as vector which contained b (note that A is left unchanged)

Package

sapa

Source

matrix.lisp (file)

Function: m-location-estimate THE-SEQ &key WEIGHTING-FUNCTIONS ITERATIONS

given
[1] the-seq (required)
==> a sequence of numbers
[2] weighting-functions (keyword; Huber and Thomson) ==> a list of two weighting functions
[3] iterations (keyword; ’(10 0))
==> a list of nonegative integers
giving the number of iterations
for each weighting function
returns
[1] m-location estimate for sequence
[2] MAD scale estimate (based upon deviations from m-location estimate)

Note: see article by Hogg in Launer and Wilkinson

Package

sapa

Source

basic-statistics.lisp (file)

Function: max-of-seq THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of real-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] maximum value in sequence
[2] index of maximum value

Package

sapa

Source

utilities.lisp (file)

Function: median-absolute-deviation THE-SEQ &key LOCATION-ESTIMATE

given
[1] the-seq (required)
==> a sequence of real-valued numbers
[2] location-estimate (keyword; median of the-seq) ==> robust estimate of location
returns
[1] the median absolute deviation about location-estimate [2] location-estimate (median of the-seq by default)

Package

sapa

Source

basic-statistics.lisp (file)

Function: min-and-max-of-seq THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of real-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] minimum value in sequence
[2] maximum value in sequence

Package

sapa

Source

utilities.lisp (file)

Function: min-of-seq THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of real-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] minimum value in sequence
[2] index of minimum value

Package

sapa

Source

utilities.lisp (file)

Function: modified-gram-schmidt! A-MATRIX

given
[1] A (required)
<=> a matrix of real or complex-valued numbers with size m by n with rank N
computes the factorization A = QR, where
Q is of size m by n and has orthonormal columns and R is of size n by n and is upper triangular, and returns
[1] Q
[2] R

Note: see Algorithm 5.2.5, p. 219, of Golub and Van Loan, Second Edition, with simple changes to handle matrices with real or complex-valued numbers

Package

sapa

Source

matrix.lisp (file)

Function: multiply-2-polynomials POLYNOMIAL-1 POLYNOMIAL-2 &key DEGREE-OF-1 DEGREE-OF-2 PRODUCT-POLYNOMIAL

given
[1] polynomial-1 (required)
==> sequence of length n+1 with real or
complex-valued numbers giving the n+1
coefficients of a polynomial of nth order;
(elt polynomial-1 i) = coefficient of z^(n-i)
[2] polynomial-2 (required)
==> another sequence representing another polynomial
[3] degree-of-1 (keyword; (1- (length polynomial-1)))
==> degree of first polynomial
[4] degree-of-2 (keyword; (1- (length polynomial-2)))
==> degree of second polynomial
[5] product-polynomial (keyword; array of length (+ degree-of-1 degree-of-2 1)) <== a sequence with product of two polynomials
returns
[1] product-polynomial, an sequence with coefficients
of polynomial given by the product of
polynomial-1 and polynomial-2

Note: this routine works for a polynomial p represented either by
p(0) + p(1)*z + ... + p(degp)*z^degp
or by
p(0)*z**degp + p(1)*z**(degp-1) + ... + p(degp)

Package

sapa

Source

basic-math.lisp (file)

Function: multiply-matrix-and-scalar A-MATRIX SCALAR &key RESULT

given
[1] a-matrix (required)
==> a 2d matrix
[2] scalar (required)
==> an arbitrary number
[3] result (keyword; new matrix of same size as a-matrix) <== a matrix to contain product of a-matrix and scalar returns
[1] product of a-matrix and scalar (placed in result)

Package

sapa

Source

matrix.lisp (file)

Function: multiply-matrix-and-vector A-MATRIX B-VECTOR &key RESULT

given
[1] a-matrix (required)
==> a 2d matrix
[2] b-vector (required)
==> a vector, with dimensions such that
the product of a-matrix and b-vector is defined [3] result (keyword; new vector of appropriate size)
<== a vector to contain product of a-matrix and b-vector returns
[1] product of a-matrix and b-vector (placed in result)

Package

sapa

Source

matrix.lisp (file)

Function: multiply-polynomials &rest POLYS

given
[1] sequences representing any number of polynomials (required) returns
[1] a sequence representing their product

Note: this function was written by Andrew G. Bruce

Package

sapa

Source

basic-math.lisp (file)

Function: multiply-sequences &rest SEQS

given
[1] a arbitrary number of sequences of numbers, all of the same size
returns
[1] a new sequence formed by multiplying the sequences together on an element by element basis

Package

sapa

Source

utilities.lisp (file)

Function: multiply-two-matrices A-MATRIX B-MATRIX &key RESULT

given
[1] a-matrix (required)
==> a 2d matrix
[2] b-matrix (required)
==> another 2d matrix, with dimensions such that the product of a-matrix and b-matrix is defined [3] result (keyword; new 2d array of appropriate size) <== a 2d matrix to contain product of two matrices returns
[1] product of two matrices (placed in result)

Package

sapa

Source

matrix.lisp (file)

Function: multitaper-spectral-estimate TIME-SERIES LIST-OF-DATA-TAPERS &key CENTER-DATA START END N-TAPERS N-NONZERO-FREQS RETURN-EST-FOR-0-FREQ-P SAMPLING-TIME SCRATCH-DFT RECENTER-AFTER-TAPERING-P RESTORE-POWER-OPTION-P SDF-TRANSFORMATION RESULT-SDF RETURN-EIGENPSPECTRA-P RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] time-series (required)
==> a sequence of time series values
[2] list-of-data-tapers (required)
==> a list of orthonormal data tapers,
each of length (- end start)
[3] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series;
if nil, time-series is not centered
[4] start (keyword; 0)
==> start index of sequence to be used
[5] end (keyword; length of time-series)
==> 1 + end index of sequence to be used
[6] N-tapers (keyword; length of list-of-data-tapers)
==> number of data tapers to be used in list-of-data-tapers
[7] N-nonzero-freqs (keyword; :half-next-power-of-2)
==> specifies at how many nonzero frequencies
multitaper spectral estimate is to be computed – choices are: :half-next-power-of-2
==> 1/2 * power of two >= sample size; :next-power-of-2
==> power of two >= sample size; :twice-next-power-of-2
==> 2 * power of two >= sample size;
:Fourier
==> just at Fourier frequencies
– or –
any power of 2 >= 1/2 * [power of two >= sample size]
[8] return-est-for-0-freq-p (keyword; nil)
==> if t, sdf is computed at zero frequency;
otherwise, it is not computed.
[9] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[10] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[11] recenter-after-tapering-p (keyword; t)
==> if t and data-taper is a function,
centers tapered series by subtracting
off its sample mean
[12] restore-power-option-p (keyword; t)
==> if t and data-taper is a function,
normalizes tapered series to have same
sum of squares as before tapering
[13] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[14] result-sdf (keyword; vector of correct length)
<== vector into which multitaper spectral estimate is placed;
it must be exactly of the length dictated
by N-nonzero-freqs and return-est-for-0-freq-p
[15] return-eigenpspectra-p (keyword; t)
==> if t, individual eigenspectra are returned in a list
(each eigenspectrum in the list is associated with
the corresponding taper in list-of-data-tapers)
[16] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the spectral estimate
are computed and returned in result-freq
[17] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
(ignored unless return-frequencies-p is true)
[18] result-freq (keyword; nil or vector of correct length)
<== not used if return-frequencies-p nil; otherwise,
vector of length N-nonzero-freqs (if return-est-for-0-freq-p is nil) or N-nonzero-freqs +1 (if return-est-for-0-freq-p is t)
into which the frequencies associated with the values
in result-sdf are placed
returns
[1] result-sdf, a vector holding
the properly transformed multitaper spectral estimate
[2] result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the properly transformed frequencies
associated with values in result-sdf,
or
nil (if return-frequencies-p is nil)
[3] the length of the vector result-sdf
[4] a list of untransformed eigenspectra (return-eigenpspectra-p is t), or
nil (if return-eigenpspectra-p is nil)

Note: see Section 7.1 of the SAPA book

Package

sapa

Source

multitaper.lisp (file)

Function: n-applications-of-three-point-smoother A-SEQ N

given
[1] a-seq (required)
==> a sequence of length 2*n + 1 or greater [2] n (required)
==> positive integer indicating the number of times the three-point smoother is to be applied
returns
[1] the result of repetitively smoothing a-seq using the function three-point-smoother

Package

sapa

Source

filtering.lisp (file)

Function: newton-raphson F F-PRIME X-LEFT X-RIGHT &key ACCURACY MAXIMUM-NUMBER-OF-ITERATIONS PREVENT-BRACKET-JUMPING-P

given
[1] f (required)
==> a function with a single argument
[2] f-prime (required)
==> another function with a single argument, this one being the first derivative of f [3] x-left (required)
==> left-hand bracket for the desired root; i.e., left-hand bracket <= desired root [4] x-right (required)
==> right-hand bracket for the desired root; i.e., desired root <= right-hand bracket [5] accuracy (keyword; (* 10.0 single-float-epsilon)) ==> desired relative accuracy for computed rood [6] maximum-number-of-iterations (keyword; 20) ==> maximum number of iterations
[7] prevent-bracket-jumping-p (keyword; t)
==> if t, allows Newton-Raphson to continue if it jumps out of the interval
[x-left, x-right];
if nil, jumping out of the interval causes an error to be signaled
returns
[1] a root of f in [x-left, x-right];
i.e., a value x in that interval
such that f(x) = 0
[2] the number of iterations required

Note: this function is based loosely on rtnewt, Section 9.4, Numerical Recipes, Second Edition

Package

sapa

Source

basic-math.lisp (file)

Function: next-power-of-2 N

given
[1] n (required)
==> an integer
returns
[1] an integer power of 2 greater than or equal to n

Package

sapa

Source

utilities.lisp (file)

Function: nyquist-frequency->sampling-time NYQUIST-FREQUENCY

given a Nyquist frequency, returns the associated sampling-time —
Note: see page 98 of the SAPA book

Package

sapa

Source

utilities.lisp (file)

Function: one-sided-freq->two-sided-freq ONE-SIDED-FREQ &key RESULT

given a vector of N frequencies
0, f_1, ..., f_{N-1},
returns the vector of 2N-1 frequencies -f_{N-1}, ..., -f_1, 0, f_1, ..., f_{N-1}

Package

sapa

Source

nonparametric.lisp (file)

Function: one-sided-sdf->two-sided-sdf ONE-SIDED-SDF &key RESULT

given a one-sided sdf
S(0), S(f_1), ..., S_(f_{N-1}) of length N,
returns the two-sized sdf
S_(-f_{N-1}), ..., S(-f_1), S(0), S(f_1), ..., S_(f_{N-1}) of length 2N-1, where S_(-f_k) = S_(f_k)

Package

sapa

Source

nonparametric.lisp (file)

Function: ordinary-least-squares-cholesky DEPENDENT-VARIABLE LIST-OF-INDEPENDENT-VARIABLES &key COMPUTE-RESIDUALS-P RESULT

given
[1] dependent-variable (required)
==> a vector
[2] list-of-independent-variables (required)
==> a list of either vectors or functions
(must be ALL vectors or ALL functions)
[3] compute-residuals-p (keyword; nil)
==> if t, residuals are computed
[4] result (keyword; new array if compute-residuals-p is t; otherwise nil) <== storage space for residuals
(not used unless compute-residuals-p is true)
returns
[1] vector with estimated parameters
[2] residuals

Note: uses Lisp versions of Cholesky factorization routines
from linpack

Package

sapa

Source

basic-statistics.lisp (file)

Function: ordinary-least-squares-q-r DEPENDENT-VARIABLE LIST-OF-INDEPENDENT-VARIABLES &key COMPUTE-RESIDUALS-P COMPUTE-STANDARD-ERRORS-P COMPUTE-CORRELATION-MATRIX-P RESIDUALS

given
[1] dependent-variable (required)
==> a vector
[2] list-of-independent-variables (required)
==> a list of either vectors, functions or mixture thereof [3] compute-residuals-p (keyword; nil)
==> if t, residuals are computed
[4] compute-standard-errors-p (keyword; nil)
==> if t, standard errors for parameter estimates are computed, along with residuals (even if compute-residuals-p is nil) [5] compute-correlation-matrix-p (keyword; nil)
==> if t, correlation matrix for parameter estimates is computed, along with residuals and standard errors (even if either of their associated keywords is nil)
[6] residuals (keyword; nil or vector)
<== storage space for residuals
(nil unless either compute-residuals-p, compute-standard-errors-p or
compute-correlation-matrix-p is true)
returns
[1] vector with parameter estimates
[2] vector with residuals
[2] standard error of residuals
[3] vector with standard errors of parameter estimates
[4] correlation matrix

Note: this routine is based on the discussion
in “Nonlinear Regression Analysis and Its Applications”
by Bates and Watts, Wiley, 1988.

Package

sapa

Source

basic-statistics.lisp (file)

Function: papoulis-bandwidth->m B_W &key SAMPLING-TIME

given desired smoothing window bandwidth B_W and sampling time, returns
[1] window parameter m required to approximately achieve B_W using the Papoulis lag window
[2] actual B_W achieved

Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: papoulis-lag-window TAU M

given the lag tau and window parameter m,
returns the value of the Papoulis lag window

Note: see equation near bottom of page 266 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: papoulis-m->bandwidth M &key SAMPLING-TIME

given window parameter m and sampling time,
returns bandwidth B_W for the Papoulis smoothing window —
Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: papoulis-n-m->degrees-of-freedom N M &key C_H

given sample size N, window parameter m and variance inflation factor C_h, returns equivalent degrees of freedom nu for Papoulis lag window

Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: parzen-bandwidth->m B_W &key SAMPLING-TIME

given desired smoothing window bandwidth B_W and sampling time, returns
[1] window parameter m required to approximately achieve B_W using the Parzen lag window
[2] actual B_W achieved

Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: parzen-lag-window TAU M

given the lag tau and window parameter m, returns the value of the Parzen lag window

Note: see the equation on page 265 of the SAPA book or Priestley, page 443, Equation (6.2.82)

Package

sapa

Source

nonparametric.lisp (file)

Function: parzen-m->bandwidth M &key SAMPLING-TIME

given window parameter m and sampling time, returns bandwidth B_W for the Parzen smoothing window —
Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: parzen-n-m->degrees-of-freedom N M &key C_H

given sample size N, window parameter m and variance inflation factor C_h, returns equivalent degrees of freedom nu for Parzen lag window

Note: see Table 269 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: periodogram TIME-SERIES &key CENTER-DATA START END N-NONZERO-FREQS RETURN-EST-FOR-0-FREQ-P SAMPLING-TIME SCRATCH-DFT SDF-TRANSFORMATION RESULT-SDF RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] time-series (required)
==> a vector of time series values
[2] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, time-series is not centered
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of time-series)
==> 1 + end index of vector to be used
[5] N-nonzero-freqs (keyword; :half-next-power-of-2)
==> specifies at how many nonzero frequencies periodogram is to be computed – choices are: :half-next-power-of-2
==> 1/2 * power of two >= sample size; :next-power-of-2
==> power of two >= sample size; :twice-next-power-of-2
==> 2 * power of two >= sample size; :Fourier
==> just at Fourier frequencies
– or –
any power of 2 >= 1/2 * [power of two >= sample size] [6] return-est-for-0-freq-p (keyword; nil)
==> if t, periodogram is computed at zero frequency; otherwise, it is not computed.
[7] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book) [8] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[9] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[10] result-sdf (keyword; vector of correct length)
<== vector into which periodogram is placed;
it must be exactly of the length dictated
by N-nonzero-freqs and return-est-for-0-freq-p [11] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the periodogram are computed and returned in result-freq
[12] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
(ignored unless return-frequencies-p is true) [13] result-freq (keyword; nil or vector of correct length) <== not used if return-frequencies-p nil; otherwise, vector of length dictated by
N-nonzero-freqs and return-est-for-0-freq-p
into which the frequencies associated with the values in result-sdf are placed
returns
[1] result-sdf, a vector holding
the properly transformed periodogram
[2] result-freq (if return-frequencies-p is t),
a vector holding the properly transformed
frequencies associated with values in result-sdf
– or –
nil (if return-frequencies-p is nil)
[3] the length of the vector result-sdf

Note: see Section 6.3 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: periodogram-at-one-frequency TIME-SERIES FREQ &key CENTER-DATA START END SAMPLING-TIME

given
[1] time-series (required)
==> a vector of time series values
[2] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series; if nil, time-series is not centered
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of time-series)
==> 1 + end index of vector to be used
[5] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book) returns
[1] value of periodogram at freq
[2] approximate conditional least squares estimate for A, the amplitude of cosine term in Equation (461a)
of the SAPA book
[3] approximate conditional least squares estimate for B the amplitude of sine term

Note: see Section 10.2 of the SAPA book

Package

sapa

Source

harmonic.lisp (file)

Function: postcolor-spectral-estimate PRECOLORED-SDF-ESTIMATE PREWHITENING-FILTER SAMPLE-SIZE &key N-NONZERO-FREQS INCLUDES-EST-FOR-0-FREQ-P SCRATCH-DFT SDF-TRANSFORMATION RESULT-SDF

given
[1] precolored-sdf-estimate (required)
==> vector containing sdf estimate to be postcolored;
note that this estimate is assumed to be untransformed (i.e., not expressed in dB, etc)
[2] prewhitening-filter (required)
==> vector with coefficients of prewhitening filter
[3] sample-size (required)
==> length of the time series from which precolored-sdf-estimate was constructed; this is needed to get corresponding
grid of frequencies
[4] N-nonzero-freqs (keyword; :half-next-power-of-2)
==> specifies at how many nonzero frequencies precolored-sdf-estimate was computed – choices are: :half-next-power-of-2
==> 1/2 * power of two >= sample size; :next-power-of-2
==> power of two >= sample size; :twice-next-power-of-2
==> 2 * power of two >= sample size;
:Fourier
==> just at Fourier frequencies
– or –
any power of 2 >= 1/2 * [power of two >= sample size]
[5] includes-est-for-0-freq-p (keyword; nil)
==> if t, first element of precolored-sdf-estimate corresponds to zero frequency
[6] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[7] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[8] result-sdf (keyword; vector of correct length)
<== vector into which postcolored sdf estimate is placed;
it must be exactly the same length as precolored-sdf-estimate returns
[1] result-sdf, a vector holding
the postcolored sdf estimate

Note: see Equation (438) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: power-of-2 N

given
[1] n (required)
==> an integer
returns
[1] nil if n is not a power of 2
– or –
m if n = 2^m for a positive integer m

Package

sapa

Source

utilities.lisp (file)

Function: predicted-y-at-x X INTERCEPT SLOPE

given
[1] x (required)
==> a number
[2] intercept (required) ==> intercept of a line [3] slope (required) ==> slope of a line returns
[1] intercept + slope*x

Package

sapa

Source

basic-statistics.lisp (file)

Function: print-1-or-2-d-array AN-ARRAY &key TAG FORMAT-CONTROL-FOR-ARRAY-ELEMENT

given
[1] an-array (required)
==> a one-dimensional or two-dimensional array [2] tag (keyword; ‘array’)
==> an optional tag to be printed
along with array elements
[3] format-control-for-array-element (keyword; ‘~F’) ==> format control for a single array element prints the elements of an-array and
returns
[1] an-array

Package

sapa

Source

matrix.lisp (file)

Function: print-rows-of-nxm-matrix AN-NXM-MATRIX &key FORMAT-CONTROL-FOR-ARRAY-ELEMENT

given
[1] an-nxm-matrix (required)
==> a two-dimensional array
[3] format-control-for-array-element (keyword; ‘~F’) ==> format control for a single array element prints the elements of the 2d array and
returns
[1] an-nxm-matrix

Package

sapa

Source

matrix.lisp (file)

Function: q-q-plot Y-VALS X-VALS &key N X-VALS-SORTED-P Y-VALS-SORTED-P

given
[1] y-vals (required)
==> a sequence or function
[2] x-vals (required)
==> a sequence or function
[3] n (keyword; 256 if y-vals is a function, length of y-vals otherwise) ==> positive integer
[4] x-vals-sorted-p (keyword; t if x-vals is a function, nil otherwise) ==> a flag indicating whether x-vals is already sorted
[5] y-vals-sorted-p (keyword; t if y-vals is a function, nil otherwise) ==> a flag indicating whether y-vals is already sorted
return
[1] y values needed to create a q-q-plot for y-vals
[2] x values

Note: For details, see Chapter 6 of “Graphical Methods for Data Analysis” by Chambers, Cleveland, Kleiner and Tukey

Package

sapa

Source

basic-statistics.lisp (file)

Function: q-r! A-MATRIX

same as modified-Gram-Schmidt!

Package

sapa

Source

matrix.lisp (file)

Function: quantile-of-chi-square-2-distribution P

given
[1] p (required)
==> a number > 0 and < 1
returns
[1] p-th quantile of chi-square distribution with 2 degrees of freedom —
Note: Equation (31), P. 640 of Chave, Thomson, and Ander (1987)

Package

sapa

Source

basic-statistics.lisp (file)

Function: quantile-of-chi-square-distribution NU P &key ACCURACY-LEVEL

given
[1] nu (required)
==> degrees of freedom
[2] p (required)
==> a number > 0 and < 1
[3] accuracy-level (keyword; :quick)
if :quick, gives quick approximation;
if :accurate, give accurate, but computationally
expensive, approximation
returns
[1] p-th quantile of chi-square distribution with nu degrees of freedom —
Note: for :quick, see Table 6.4, page 225,
“Graphical Methods for Data Analysis”
by Chambers, Cleveland, Kleiner, & Tukey;
if :accurate, see AS 91, Applied Statistics

Package

sapa

Source

basic-statistics.lisp (file)

Function: quantile-of-exponential-distribution P

given
[1] p (required)
==> a number > 0 and < 1
returns
[1] p-th quantile of exponential distribution with mean 1 —
Note: Table 6.4, page 225, “Graphical Methods for Data Analysis” by Chambers, Cleveland, Kleiner, & Tukey

Package

sapa

Source

basic-statistics.lisp (file)

Function: quantile-of-gamma-distribution ALPHA P

given
[1] alpha (required)
==> shape parameter for gamma distribution
[2] p (required)
==> a number > 0 and < 1
returns
[1] p-th quantile of standard gamma distribution

Note: Table 6.4, page 225, “Graphical Methods for Data Analysis” by Chambers, Cleveland, Kleiner, & Tukey

Package

sapa

Source

basic-statistics.lisp (file)

Function: quantile-of-kolmogorov-test-statistic SAMPLE-SIZE &key SIGNIFICANCE-LEVEL

given
[1] sample-size (required)
==> a positive integer
[2] significance-level (keyword; 0.95)
==> 0.99, 0.98, 0.95, 0.90, or 0.80;
0.75 is also ok if sample-size > 40
returns
[1] quantile of two-sided Kolmogorov test statistic —
Note: see Table 14, page 462, of Conover (2nd edition, 1980); Stephens (1974); and Diggle (1990, page 55); significance-level is currently limited to one of these values: 0.99, 0.98, 0.95, 0.90, or 0.80;
if sample-size is greater than 40, 0.75 is also ok

Package

sapa

Source

nonparametric.lisp (file)

Function: quantile-of-normal-distribution P &key ACCURACY-LEVEL

given
[1] p (required)
==> a number > 0 and < 1
[2] accuracy-level (keyword; :quick)
==> if :quick, gives quick approximation;
if :better, gives slower, but better, approximation; if :accurate, uses slowest, but more accurate, approximation;
returns
[1] quantile of standard normal distribution;

Note: for :quick, see Table 6.5, page 227,
“Graphical Methods for Data Analysis”
by Chambers, Cleveland, Kleiner, & Tukey;
for :better, see Sections 26.2.22 and 26.2.23
of Abramowitz and Stegun;
for :accurate, see AS 111 by Beasley and Springer, Applied Statistics, 1977, vol. 26, p.118

Package

sapa

Source

basic-statistics.lisp (file)

Function: quantile-of-ordered-seq THE-SEQ P

given
[1] the-seq (required)
==> a sequence of real-valued numbers,
ordered from smallest to largest
[2] p (required)
==> a percentile; i.e., 0 <= p <= 1
returns
[1] the sample quantile for p

Note: see Section 2.2 of “Graphical Methods for Data Analysis” by Chambers, Cleveland, Kleiner, and Tukey

Package

sapa

Source

basic-statistics.lisp (file)

Function: quantile-plot A-SEQ &key A-SEQ-SORTED-P

given
[1] a-seq (required)
==> any sequence of real-valued numbers
[2] a-seq-sorted-p (keyword; nil)
==> if t, a-seq is already sorted;
if nil, a copy of a-seq is sorted
for use by the function
returns
[1] sequence with sample quantiles for a-seq
[2] sequence with corresponding percentiles

Note: see Section 2.2 of “Graphical Methods for Data Analysis” by Chambers, Cleveland, Kleiner, and Tukey

Package

sapa

Source

basic-statistics.lisp (file)

Function: ranorm ()

returns a random deviate from a normal distribution with zero mean and unit variance

Package

sapa

Source

random.lisp (file)

Function: ranorms N &key RESULT

given:
[1] n (required)
==> number of normal random deviates
to be generated
[2] result (keyword; vector of length n)
<== vector to hold random deviates returns:
[1] result, a vector with n normal random deviates (i.e., a realization of length n of a white noise process from a normal distribution)

Package

sapa

Source

random.lisp (file)

Function: reflection-coeffs->ar-coeffs REFLECTION-COEFFS &key P SCRATCH RESULT

given
[1] reflection-coeffs (required)
==> vector of length p with real-valued reflection coefficients
phi_{1,1}, phi_{2,2}, ... , phi_{p,p}
[2] p (keyword; length of reflection-coeffs)
==> AR model order
[3] scratch (keyword; vector of length p)
==> vector of size p used for intermediate results [4] results (keyword; vector of length p)
<== vector of size p into which are placed
the AR coefficients phi_{j,p} for model
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2} + ... + phi_{p,p} * x_{t-p} + e_t returns
[1] results, i.e., the AR coefficients

Note: see Section 9.4 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: reflection-coeffs->variance REFLECTION-COEFFS INNOVATIONS-VARIANCE &key P

given
[1] reflection-coeffs (required)
==> vector of length p with real-valued reflection coefficients phi_{1,1}, phi_{2,2}, ... , phi_{p,p} [2] innovations-variance (required)
==> innovations variance of the process [3] p (keyword; length of reflection-coeffs) ==> AR model order
returns
[1] variance of the process

Note: this is a recursive application of Equation (404c) of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: regression-with-ar-errors TIME-SERIES IND-VARS P &key AR-COEFF-ESTIMATOR MAXIMUM-NUMBER-OF-ITERATIONS EPS TRACE-AR-PARAMETER-ESTIMATES-P TRACE-LS-PARAMETER-ESTIMATES-P

given
[1] time-series (required)
==> a vector with dependent variables
[2] ind-vars (required)
==> a list of vector(s) with independent variable(s) [3] p (required)
==> autoregressive order
[4] AR-coeff-estimator (keyword; #’burg-algorithm)
==> AR estimation procedure
[5] maximum-number-of-iterations (keyword; 5)
==> ... like I said ...
[6] eps (keyword; 1.0e-7)
==> a small number – used to test for convergence in estimates of both regression and AR coefficients [7] trace-AR-parameter-estimates-p (keyword; nil)
==> if t, results of each iteration
on AR parameters are printed
[8] trace-LS-parameter-estimates-p (keyword; nil)
==> if t, results of each iteration
on least squares parameters are printed
returns
[1] estimates of least squares coefficients
[2] estimates of AR coefficients
[3] variance of residuals
[4] either number of iterations required for convergence or nil if maximum number of iterations completed but convergence not yet achieved

Note: this function is based on Newton, TIMESLAB, page 241; it has NOT been thoroughly tested (particularly with regard to the convergence criterion),
so a heavy dose of the usual “caveat emptor”
is appropriate here!!!

Package

sapa

Source

parametric.lisp (file)

Function: running-median TIME-SERIES K &key RESULT

given
[1] time-series (required)
==> a sequence of numbers
[2] K (required)
==> positive integer giving the number of points in the running median
[3] result (keyword; vector of appropriate length) <== a sequence to hold running medians
of time series
return
[1] result, the vector of running medians
of K consecutive points

Package

sapa

Source

filtering.lisp (file)

Function: sample-cepstrum LOG-SPECTRUM &key SAMPLING-TIME ZERO-FREQUENCY-P NYQUIST-FREQUENCY-P RESULT

given
[1] log-spectrum (required)
==> a vector containing log spectrum
[2] sampling-time (keyword; 1.0)
==> the sample time (i.e., delta t)
[3] zero-frequency-p (keyword; nil)
==> if t, the first element of log-spectrum
is associated with 0 frequency;
if nil, first element goes with
lowest nonzero frequency
[4] Nyquist-frequency-p (keyword; nil)
==> if t, the last element of log-spectrum
is associated with Nyquist frequency;
if nil, last element goes with
a frequency just less than Nyquist
[5] result (keyword; vector of appropriate length)
<== vector to hold sample cepstrum
returns
[1] result, i.e., the sample cepstrum from lag 0 to lag N_U
where N_U = length of log-spectrum - 1 if zero-frequency-p is t or = length of log-spectrum if zero-frequency-p is nil —
Note: see Equation 282 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: sample-correlation-coefficient SEQ-1 SEQ-2 &key START END

given
[1] seq-1 (required)
==> a sequence of real-valued numbers [2] seq-2 (required)
==> another sequence of real-valued numbers; should have the same length as seq-1 [3] start (keyword; 0)
==> start index of sequence to be used [4] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] sample correlation coefficient
between two sequences

Package

sapa

Source

basic-statistics.lisp (file)

Function: sample-from-a-function A-FUNCTION &key SEQ-OF-X-VALUES X0 DELTA-X N

given
[1] a-function (required)
==> a function to be sampled from
[2] seq-of-x-values (keyword; ’())
==> sequence of values at which a-function
is to be sampled (default ’())
[3] x0 (keyword; 0.0)
==> point of first value to be sampled
[4] delta-x (keyword; 1.0)
==> increment between points
[5] n (keyword; length of seq-of-x-values)
==> number of samples
returns
[1] an array with the values of a-function
at a specified set of points; and
[2] an array with the specified set of points.

Note that the specified set of points either is in seq-of-x-values – if it is non-nil – or is given by
x0, x0 + delta-x, x0 + 2*delta-x, ..., x0 + (n-1)*delta-x

Package

sapa

Source

utilities.lisp (file)

Function: sample-mean THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of real or complex-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used
[3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] sample mean of the specified numbers
in the-seq

Package

sapa

Source

basic-statistics.lisp (file)

Function: sample-mean-and-variance THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of real or complex-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used
[3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] sample mean of the specified numbers
in the-seq
[2] sample variance of the specified numbers
in the-seq

Package

sapa

Source

basic-statistics.lisp (file)

Function: sample-median THE-SEQ &key START END THE-SEQ-IS-ORDERED-P

given
[1] the-seq (required)
==> a sequence of real-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used [4] the-seq-is-ordered-p (keyword; nil) ==> if t, the-seq is assumed to
be sorted from smallest to largest value; if nil, the-seq will be sorted returns
[1] sample median
[2] minimum value in sequence
[3] maximum value
[4] sorted sequence

Package

sapa

Source

basic-statistics.lisp (file)

Function: sample-skewness-and-kurtosis THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of real-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] sample skewness of the specified numbers in the-seq
[2] sample kurtosis
[3] sample mean
[4] sample variance

Package

sapa

Source

basic-statistics.lisp (file)

Function: sample-variance THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of real or complex-valued numbers [2] start (keyword; 0)
==> start index of sequence to be used
[3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] sample variance of the specified numbers
in the-seq

Package

sapa

Source

basic-statistics.lisp (file)

Function: sample-variogram TIME-SERIES TIMES

given:
[1] time-series (required)
==> a vector containing the time series [2] times (required)
==> a vector containing the associated times returns
[1] the sample variogram
[2] associated lags

Note: see Diggle’s book

Package

sapa

Source

acvs.lisp (file)

Function: sampling-time->nyquist-frequency SAMPLING-TIME

given a sampling time, returns the associated Nyquist frequency —
Note: see page 98 of the SAPA book

Package

sapa

Source

utilities.lisp (file)

Function: sdf->sdf-with-accurate-peaks SDF FREQS AR-COEFFS INNOVATIONS-VARIANCE &key SAMPLING-TIME SDF-TRANSFORMATION SEARCH-METHOD DB-TOLERANCE ACCURACY MAXIMUM-NUMBER-OF-ITERATIONS

given
[1] sdf (required)
==> vector with sdf for a real-valued process
computed over a grid of frequencies (the grid
need not be uniform) – note that the sdf values
can be either untransformed or transformed via
an order preserving transformation (such as decibels)
[2] freqs (required)
==> vector with frequencies corresponding to values
in sdf (must be same size as vector with sdf values)
[3] AR-coeffs (required)
==> vector with real-valued AR coefficients phi_{j,p}
for an AR(p) model of order p:
x_t = phi_{1,p} * x_{t-1} + phi_{2,p} * x_{t-2}
+ ... + phi_{p,p} * x_{t-p} + e_t
[4] innovations-variance (required)
==> innovations variance of the process
[5] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[6] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform any newly computed values of the sdf
[7] search-method (keyword; :quadratic-approx)
==> selects between two methods to search
for the location of peaks;
if set to :quadratic-approx, a quadratic approximation is used; if set to :bisection+Newton-Raphson, an interval search using a combination of bisection and Newton-Raphson is used [8] dB-tolerance (keyword; 0.1)
==> convergence criterion (used if search-method
is :quadratic-approx)
[9] accuracy (keyword; 10 * single-float-epsilon)
==> convergence criterion (used if search-method
is :bisection+Newton-Raphson)
[10] maximum-number-of-iterations (keyword; 20)
==> controls the number of iterations (used if search-method
is :bisection+Newton-Raphson)
returns
[1] a vector with values of sdf merged
with an additional set of values
chosen to represent peaks accurately
[2] the corresponding augmented vector of frequencies
[3] the length of the two vector returned

Note: see pages 524–5 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: secant-method F X-LEFT X-RIGHT &key ACCURACY MAXIMUM-NUMBER-OF-ITERATIONS

given
[1] f (required)
==> a function with a single argument
[2] x-left (required)
==> left-hand bracket for the desired root; i.e., left-hand bracket <= desired root [3] x-right (required)
==> right-hand bracket for the desired root; i.e., desired root <= right-hand bracket [4] accuracy (keyword; (* 10.0 single-float-epsilon)) ==> desired relative accuracy for computed rood [5] maximum-number-of-iterations (keyword; 50) ==> maximum number of iterations
returns
[1] a root of f in [x-left, x-right];
i.e., a value x in that interval
such that f(x) = 0
[2] the number of iterations required

Note: this function is based loosely on rtsec, Section 9.2, Numerical Recipes, Second Edition

Package

sapa

Source

basic-math.lisp (file)

Function: sign A1 A2

implementation of Fortran SIGN function

Package

sapa

Source

utilities.lisp (file)

Function: simple-numerical-integration F A B &key ACCURACY MAXIMUM-NUMBER-OF-ITERATIONS

given
[1] f (required)
==> a function with a single argument
[2] a (required)
==> left-hand limit for numerical integration [3] b (required)
==> right-hand limit for numerical integration i.e., a < b
[4] accuracy (keyword; 1.0e-6)
==> desired relative accuracy for computed rood [5] maximum-number-of-iterations (keyword; 20) ==> maximum number of iterations
returns
[1] the integral of f over the interval [a, b] [2] the number of iterations required

Note: this function is based on qtrap,
Section 4.2, Numerical Recipes, Second Edition

Package

sapa

Source

basic-math.lisp (file)

Function: simulate-time-series-from-sdf N-SERIES SDF &key SAMPLING-TIME N-TOTAL RESULT

given
[1] n-series (required)
==> length of time series to be simulated
[2] sdf (required)
==> spectral density function (sdf) defined for
0 <= f <= 1/(2.0 sampling-time) – the
sdf is assumed to be two-sided and symmetric
about f = 0
[3] sampling-time (keyword; 1.0)
==> the assumed sampling time (delta t)
[4] n-total (keyword; 4 * next power of 2 for n-series)
==> a power of 2 controlling degree of accuracy
of the approximation (the larger, the better –
see Percival, 1992, for details)
[5] result (keyword; vector of length n-series)
<== a vector to contain simulated time series
returns
[1] a vector of length n-series generated from sdf

Note: the method used here is an approximate frequency domain technique; in particular, it will NOT simulate the DC component correctly, so beware of using this function in studies where the process mean is of important

Package

sapa

Source

random.lisp (file)

Function: smoothing-window-for-lag-window-spectral-estimate SAMPLE-SIZE LAG-WINDOW-FUNCTION &key N-NONZERO-FREQS SAMPLING-TIME SCRATCH-DFT SMOOTH-WIND-TRANSFORMATION RESULT-SMOOTH-WIND RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] sample-size (required)
==> sample size for which smoothing window is to be computed [2] lag-window-function (required)
==> function of a single variable that computes the value
of the lag window for a given lag
[3] N-nonzero-freqs (keyword; :twice-next-power-of-2)
==> specifies at how many nonzero frequencies
smoothing window is to be computed – choices are: :half-next-power-of-2
==> 1/2 * power of two >= sample size; :next-power-of-2
==> power of two >= sample size; :twice-next-power-of-2
==> 2 * power of two >= sample size; :Fourier
==> just at Fourier frequencies
– or –
any power of 2 >= 1/2 * [power of two >= sample size] [4] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[5] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[6] smooth-wind-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-smooth-wind
[7] result-smooth-wind (keyword; vector of correct length)
<== vector into which smoothing window values are placed;
it must be exactly of the length dictated by N-nonzero-freqs [8] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the smoothing window are computed and returned in result-freq
[9] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
(ignored unless return-frequencies-p is true)
[10] result-freq (keyword; nil or vector of correct length)
<== not used if return-frequencies-p nil; otherwise,
vector of N-nonzero-freqs +1 into which
the frequencies associated with the values
in result-smooth-wind are placed
returns
[1] result-smooth-wind, a vector holding
the properly transformed smoothing window
[2] result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the properly transformed frequencies
associated with values in result-smooth-wind
– or –
nil (if return-frequencies-p is nil)
[3] the length of the vector result-smooth-wind

Note: see equation below Equation (237c) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: spectral-window-for-direct-spectral-estimate SAMPLE-SIZE &key N-NONZERO-FREQS SAMPLING-TIME SCRATCH-DFT DATA-TAPER DATA-TAPER-PARAMETERS SPEC-WIND-TRANSFORMATION RESULT-SPEC-WIND RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] sample-size (required)
==> sample size for which spectral window is to be computed [2] N-nonzero-freqs (keyword; :twice-next-power-of-2)
==> specifies at how many nonzero frequencies
spectral window is to be computed – choices are: :half-next-power-of-2
==> 1/2 * power of two >= sample size; :next-power-of-2
==> power of two >= sample size; :twice-next-power-of-2
==> 2 * power of two >= sample size; :Fourier
==> just at Fourier frequencies
– or –
any power of 2 >= 1/2 * [power of two >= sample size] [3] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[4] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[5] data-taper (keyword; nil)
==> nil or a tapering function
[6] data-taper-parameters (keyword)
==> parameters for tapering function (not used
if data-taper is nil)
[7] spec-wind-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-spec-wind
[8] result-spec-wind (keyword; vector of correct length)
<== vector into which spectral window values are placed;
it must be exactly of the length dictated by N-nonzero-freqs [9] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the spectral window are computed and returned in result-freq
[10] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
[11] result-freq (keyword; nil or vector of correct length)
<== not used if return-frequencies-p nil; otherwise,
vector of N-nonzero-freqs +1 into which
the frequencies associated with the values
in result-spec-wind are placed
returns
[1] result-spec-wind, a vector holding
the properly transformed spectral window
[2] result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the properly transformed frequencies
associated with values in result-spec-wind
– or –
nil (if return-frequencies-p is nil)
[3] the length of the vector result-spec-wind

Note: see equation below Equation (207a) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: spectral-window-for-lag-window-spectral-estimate SAMPLE-SIZE LAG-WINDOW-FUNCTION &key N-NONZERO-FREQS SAMPLING-TIME SCRATCH-DFT DATA-TAPER DATA-TAPER-PARAMETERS SPEC-WIND-TRANSFORMATION RESULT-SPEC-WIND RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] sample-size (required)
==> sample size for which spectral window is to be computed [2] lag-window-function (required)
==> function of a single variable that computes the value
of the lag window for a given lag
[3] N-nonzero-freqs (keyword; :twice-next-power-of-2)
==> specifies at how many nonzero frequencies
spectral window is to be computed – choices are: :half-next-power-of-2
==> 1/2 * power of two >= sample size; :next-power-of-2
==> power of two >= sample size; :twice-next-power-of-2
==> 2 * power of two >= sample size; :Fourier
==> just at Fourier frequencies
– or –
any power of 2 >= 1/2 * [power of two >= sample size] [4] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[5] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[6] data-taper (keyword; nil)
==> nil or a tapering function
[7] data-taper-parameters (keyword)
==> parameters for tapering function (not used
if data-taper is nil)
[8] spec-wind-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-spec-wind
[9] result-spec-wind (keyword; vector of correct length)
<== vector into which spectral window values are placed;
it must be exactly of the length dictated by N-nonzero-freqs [10] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the spectral window are computed and returned in result-freq
[11] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
(ignored unless return-frequencies-p is true)
[12] result-freq (keyword; nil or vector of correct length)
<== not used if return-frequencies-p nil; otherwise,
vector of N-nonzero-freqs +1 into which
the frequencies associated with the values
in result-spec-wind are placed
returns
[1] result-spec-wind, a vector holding
the properly transformed spectral window
[2] result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the properly transformed frequencies
associated with values in result-spec-wind
– or –
nil (if return-frequencies-p is nil)
[3] the length of the vector result-spec-wind

Note: see equation below Equation (244a) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: spofa! A &key N

given
[1] A (required)
<=> real symmetric positive definite matrix (this gets trashed)
[2] n (keyword; (array-dimensions a))
==> size of matrix to be factored calculates the upper triangular matrix U
of the Cholesky decomposition A = LU,
where L = U^T, and
returns
[1] U, stored in upper triangular part of A

Package

sapa

Source

matrix.lisp (file)

Function: sposl! A B &key N

given
[1] A (required)
==> real symmetric positive definite matrix
AFTER it has been crunched by spofa!
[2] b (required)
<=> the right-hand side vector on input;
on output, this gets replaced by the solution X [3] N (keyword; length of b)
==> order of matrix A (default is length of b) returns
[1] X, the solution to A X = b; note that X is the same as the vector which contained b

Package

sapa

Source

matrix.lisp (file)

Function: standard-normal-pdf X

given x, returns value of standard normal pdf at x

Package

sapa

Source

basic-statistics.lisp (file)

Function: step-down-levinson-durbin-recursions COEFFS VARIANCE &key PROCESS-VARIANCE-P

given
[1] coeffs (required)
==> sequence of length p with AR coefficients:
x_t = coeffs_0*x_{t-1} + coeffs_1*x_{t-2}
+ ... + coeffs_{p-1}*x_{t-p} + e_t
(see Equation (392a) in the SAPA book;
the coefficients can be real or complex-valued)
[2] variance (required)
==> process variance or innovations variance
(see keyword process-variance-p)
[3] process-variance-p (keyword; t)
==> if t, variance is taken to be process variance
if nil, variance is taken to be innovations variance
computes best linear prediction coefficients of orders 1, 2, ..., p-1 and prediction error variances of orders 0 (process variance), 1, ..., p and returns
[1] list of vectors with best linear prediction coefficients
going from order 1 to order p;
[2] list of prediction error variances going from order 0 to order p —
Note: see item [4] of the Comments and Extensions
to Section 9.4 of the SAPA book. The values returned by
this function can be used to set the keyword parameters list-of-lower-order-phi and list-of-lower-order-pev in
the function generate-ar-time-series

Package

sapa

Source

random.lisp (file)

Function: subtract-two-matrices A-MATRIX B-MATRIX &key RESULT

given
[1] a-matrix (required)
==> a 2d matrix
[2] b-matrix (required)
==> a 2d matrix, with dimensions the same
as a-matrix
[3] result (keyword; new vector of appropriate size) <== a matrix to contain result of subtracting b-matrix from a-matrix
returns
[1] a-matrix minus b-matrix (placed in result)

Package

sapa

Source

matrix.lisp (file)

Function: sum THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of numbers
[2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] sum of elements in specified subsequence

Package

sapa

Source

utilities.lisp (file)

Function: sum-of-squares THE-SEQ &key START END

given
[1] the-seq (required)
==> a sequence of numbers
[2] start (keyword; 0)
==> start index of sequence to be used [3] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] sum of squares of elements
in specified subsequence

Package

sapa

Source

utilities.lisp (file)

Function: supplied-data-taper! A-TIME-SERIES &key TAPER-PARAMETER NORMALIZATION RESULT

given
[1] a-time-series (required)
<=> a vector containing a time series;
this vector is modified UNLESS keyword result
is bound to a different vector
[2] taper-parameter (keyword; vector with Hanning taper) ==> a vector containing the supplied data taper
(must be the same length as a-time-series); unmodified upon return
[3] normalization (keyword; :unity)
==> if :unity, taper normalized such that
its sum of squares is equal to unity (Equation (208a)); if :N, taper normalized such that
its sum of squares is equal to the number of points in the time series
[4] result (keyword; a-time-series)
<=> a vector to contain time series multiplied
by the supplied data taper
returns
[1] a vector containing the tapered time series
[2] C_h, the variance inflation factor
computed using Equation (251b) in the SAPA book

Package

sapa

Source

tapers.lisp (file)

Function: symmetry-plot A-SEQ &key A-SEQ-SORTED-P

given
[1] a-seq (required)
==> any sequence of real-valued numbers [2] a-seq-sorted-p (keyword; nil)
==> if t, a-seq is already sorted; if nil, a copy of a-seq is sorted for use by the function
returns
[1] y values for a symmetry plot for a-seq [2] x values for a symmetry plot for a-seq

Package

sapa

Source

basic-statistics.lisp (file)

Function: tail-area-of-normal-distribution Q &key Q-TO-INFINITY-P

given
[1] q (required)
==> a quantile
[2] q-to-infinity-p (keyword; nil)
==> if t, return integral from q to +infinity; if nil, return integral from -infinity to q return
tail area of the standard norm from
either q to +infinity (if q-to-infinity-p is true) or -infinity to q (if q-to-infinity-p is nil) —
see Algorithm AS-66, Applied Statistics,
1973, vol. 22, no. 3

Package

sapa

Source

basic-statistics.lisp (file)

Function: thomson-weight-function X &key BETA SYMMETRIC-VERSION

given
[1] x (required)
==> value at which to evaluate Thomson’s
weight function
[2] beta (keyword; 1.0)
==> tuning parameter
[3] symmetric-version (keyword; t)
==> one-sided or two-sided down weightings
returns
[1] value of Thomson’s weight function at x

Note: Equation (27), p. 637 of Chave, Thomson, and Ander (1987)

Package

sapa

Source

basic-statistics.lisp (file)

Function: three-point-smoother A-SEQ

given a sequence of length N,
returns a sequence of length N-2 formed by filtering the input sequence with a three-point filter with coefficients 1/4, 1/2 and 1/4

Note: see Section 5.7 of the SAPA book

Package

sapa

Source

filtering.lisp (file)

Function: time-series-bandwidth ACVS &key SAMPLING-TIME

given
[1] acvs (required)
==> a vector of length N with values of
the acvs (or acs) from lag 0 to N-1
[2] sampling-time (keyword; 1.0)
==> the sampling time
returns
[1] unbiased estimate of trace bandwidth
(tilde B_T in Equation (280))
[2] biased estimate of trace bandwidth
(hat B_T in equation just above Equation (28))) —
Note: see Section 6.14 of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: trace-matrix A-MATRIX

given a square matrix, returns its trace

Package

sapa

Source

matrix.lisp (file)

Function: transfer-function-for-filter THE-FILTER &key TF-TRANSFORMATION ACTUAL-INDEX-OF-1ST-FILTER-COEFF N-FFT RETURN-FREQUENCIES-P NYQUIST-FREQUENCY RESULT-TF RESULT-FREQ

given
[1] the-filter (required)
==> a vector of filter coefficients
[2] tf-transformation (keyword; mod squared in dB with 0 mapped to -100 dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all of the elements of the transfer function
[3] actual-index-of-1st-filter-coeff (keyword; 0)
==> the filter coefficient in (aref the-filter 0) is assumed
to have an index equal to whatever is given here
(this is only needed if the phase of the transfer function
is needed)
[4] N-fft (keyword; 4 * (next-power-of-2 (length the-filter)))
==> the length of vector to be used in the fast Fourier transform
– the larger this is, the finer the grid of frequencies
over which the transfer function is computed; this number
MUST be a power of 2.
[5] return-frequencies-p (keyword; nil)
==> if t, the frequencies associated with the transfer function
are computed and returned in result-freq
[6] Nyquist-frequency (keyword; 0.5)
==> the Nyquist frequency
[7] result-tf (keyword; vector of length (1+ (/ N-fft 2)))
<== vector of length (1+ (/ N-fft 2))
into which the properly transformed transfer function
is placed (returned by the function)
[8] result-freq (keyword; vector of length (1+ (/ N-fft 2)) if return-frequencies-p t) <== vector of length (1+ (/ N-fft 2))
into which the frequencies associated with the values
in result-tf are placed if return-frequencies-p is true
(returned by the function)
returns
[1] result-tf, a vector holding
the properly transformed transfer function
[2] nil (if return-frequencies-p is nil) or
result-freq (if return-frequencies-p is t),
where result-freq is a vector holding
the frequencies associated with values
in result-tf

Note: see Section 5.3 of the SAPA book

Package

sapa

Source

filtering.lisp (file)

Function: transform-a-sequence A-FUNCTION THE-SEQ

given
[1] a-function (required)
==> a function with one argument
[2] the-seq (required)
==> a sequence of numbers
returns
[1] a sequence of numbers obtained by applying a-function to each element of the-seq

Package

sapa

Source

utilities.lisp (file)

Function: transform-a-sequence! A-FUNCTION THE-SEQ &key RESULT

given
[1] a-function (required)
==> a function with one argument
[2] the-seq (required)
==> a sequence of numbers
[3] result (keyword; the-seq)
<== a sequence of numbers
returns
[1] a sequence of numbers obtained by applying a-function to each element of the-seq

Package

sapa

Source

utilities.lisp (file)

Function: transpose A-MATRIX &key RESULT

given
[1] A (required)
==> a 2d matrix
[2] result (keyword; new 2d array of appropriate size) <== a 2d matrix to contain transpose of a-matrix returns
[1] transpose of a-matrix (placed in result)

Package

sapa

Source

matrix.lisp (file)

Function: triangular-convergence-factors K FILTER-LENGTH
Package

sapa

Source

filtering.lisp (file)

Function: trig-prolate-tapers N NUMBER-OF-TAPERS &key TAPER-PARAMETER PRINT-PROGRESS-P COMPUTE-TRUE-EIGENVALUES-P

given
[1] N (required)
the sample size
[2] number-of-tapers (required)
number of orthonormal trig prolate tapers
to be computed; currently restricted to
one of the following maximum values:
2 if taper-parameter is 2;
4 if taper-parameter is 3;
5 if taper-parameter is 4;
7 if taper-parameter is 5
[3] taper-parameter (keyword; 4.0)
NW, the duration-half-bandwidth product;
currently restricted to one of the
following integers: 2, 3, 4, 5
(must also be such that 0 < NW/N < 1/2)
[4] print-progress-p (keyword; nil)
if t, prints a dot after each taper
has been computed
[5] compute-true-eigenvalues-p (keyword; nil)
if t, returns eigenvalues for eigenproblem
of Equation (378) of the SAPA book;
if nil, returns nil
returns
[1] a list of length number-of-tapers of N dimensional vectors with orthonormal trig prolate data tapers of orders
0, 1, ..., number-of-tapers - 1;
[2] a vector of length number-of-tapers with
eigenvalues if compute-true-eigenvalues-p is t;
nil if if compute-true-eigenvalues-p is nil

Note: computes the trig prolate approximation to
the dpss tapers (see Section 8.4 of the SAPA book)

Package

sapa

Source

multitaper.lisp (file)

Function: trigamma X &key X-RECURSION

given
[1] x (required)
==> a positive number
[2] x-recursion (keyword; 2.0)
==> if x < x-recursion,
recursive formula is used
returns
[1] value of trigamma function at x

Note: expansion 6.4.12 plus recurrence 6.4.6
of Abramowitz and Stegun;
better accuracy can be obtained by increasing x-recursion —10.0 to 30.0 is probably a useful upper limit

Package

sapa

Source

basic-math.lisp (file)

Function: two-step-burg-algorithm TIME-SERIES P &key START END CENTER-DATA AR-COEFFS APPROXIMATE-MSES REFLECTION-COEFFS FORWARD-PREDICTION-ERRORS BACKWARD-PREDICTION-ERRORS EXACT-MSES

given
[1] time-series (required)
==> a vector containing a real-valued or
complex-valued time series x_t
[2] p (required)
==> autoregressive model order;
p should be an EVEN integer > 0 and < end - start
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of vector to be used
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series;
if nil, the effect of this function is to return
a copy of the relevant portion of time-series
[6] AR-coeffs (keyword; a vector of length p)
<== estimates of AR coefficients phi_{1,p}, ..., phi_{p,p}
[7] approximate-MSEs (keyword; a vector of length p+1)
<== estimates of innovations variance (mean square errors)
for models of order 0, 1, ..., p (the innovations variance
for the zeroth order model is the sample variance)
[8] reflection-coeffs (keyword; a vector of length p)
<== estimates of reflection coefficients phi_{1,1}, ..., phi_{p,p} [9] forward-prediction-errors (keyword; a vector of length end - start - p) <== computed forward prediction errors
[10] backward-prediction-errors (keyword; a vector of length end - start - p) <== computed backward prediction errors
[11] exact-MSEs (keyword; a vector of length p+1)
<== another set of estimates of innovations variance
for models of order 0, 1, ..., p; these estimates
are based on Equation (419a) of the SAPA book
uses the two step Burg algorithm to estimate the phi’s in the model
x_t = phi_{1,p} x_{t-1} + ... + phi_{p,p} x_{t-p} + e_t
and returns
[1] AR-coeffs, a vector containing phi_{1,p}, ..., phi_{p,p}
[2] estimate of the innovations variance, i.e.,
the variance of the e_t’s; this number is also given in
(elt approximate-MSEs p)
[3] approximate-MSEs
[4] reflection-coeffs
[5] forward-prediction-errors
[6] backward-prediction-errors
[7] exact-MSEs

Note: see Section 9.5 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: upper-triangular-solve! A B &key N

given
[1] A (required)
==> upper n by n triangular matrix
(note: lower subdiagonal part of this matrix is ignored) [2] b (required)
<=> on input, the right-hand side vector;
on output, the solution X to A X = b
[3] n (keyword; length of b)
==> order of matrix A
returns
[4] X, the solution to A X = b, where X is the same as vector which contained b (note that A is left unchanged)

Package

sapa

Source

matrix.lisp (file)

Function: var-predicted-mean-at-x X COVARIANCE-MATRIX

given
[1] x (required)
==> a number
[2] covariance-matrix (required)
==> covariance matrix for estimated intercept and slope as returned by weighted-linear-least-squares returns
[1] the variance of the predicted mean of y at x

Note: see page 56, Draper and Smith, 1966

Package

sapa

Source

basic-statistics.lisp (file)

Function: var-predicted-y-at-x X RESIDUAL-VARIANCE COVARIANCE-MATRIX

given
[1] x (required)
==> a number
[2] residual-variance (required)
==> the residual variance as returned
by weighted-linear-least-squares
[3] covariance-matrix (required)
==> covariance matrix for estimated
intercept and slope as returned
by weighted-linear-least-squares
returns
[1] the variance of the predicted value of y
at x

Note: see Equation (1.4.8), p. 24, Draper and Smith, 1966

Package

sapa

Source

basic-statistics.lisp (file)

Function: weighted-linear-least-squares Y &key VERSUS WEIGHTS COMPUTE-RESIDUALS-P COMPUTE-COVARIANCE-MATRIX-P RESIDUALS

given
[1] y (required)
==> a sequence with values of y_k’s, the dependent variable. [2] versus (keyword; equally spaced & centered values)
==> a sequence or function giving values of x_k’s,
the independent variable
[3] weights (keyword; nil)
==> if vector supplied, these are used as weights
on the observations (nil implies that all y_k’s
are equally weighted)
[4] compute-residuals-p (keyword; nil)
==> if t, residuals are computed
[5] compute-covariance-matrix-p (keyword; nil)
==> if t, calculates and returns 2x2 var/covar matrix [6] residuals (keyword; nil or vector)
<== a sequence to be stuffed with the residuals
(not used unless compute-residuals-p is true)
fits model y_k = alpha + beta * x_k, and
returns
[1] estimate of intercept alpha
[2] estimate of slope beta
[3] estimate of residual variance
[4] residuals (if compute-residuals-p is true)
[5] covariance matrix for parameter estimates
(if compute-covariance-matrix-p is true)

Note: see Chapter 2 of Draper and Smith, 1966

Package

sapa

Source

basic-statistics.lisp (file)

Function: weighted-mean THE-SEQ &key WEIGHTS START END

given
[1] the-seq (required)
==> a sequence of real or complex-valued numbers [2] weights (keyword; nil)
==> a sequence with (- end start) values
to be used as weights; if set to nil, equal weights for all numbers
is assumed
[3] start (keyword; 0)
==> start index of sequence to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of sequence to be used returns
[1] the weighted average of the specified numbers in the-seq

Package

sapa

Source

basic-statistics.lisp (file)

Function: window-width-from-silverman A-SEQ

given a-seq,
returns the window width for kernel pdf estimation given on page 48, Equation (3.31), of Silverman, 1986

Package

sapa

Source

basic-statistics.lisp (file)

Function: wosa-spectral-estimate TIME-SERIES BLOCK-SIZE &key PROPORTION-OF-OVERLAP OVERSAMPLING-FACTOR CENTER-DATA START END RETURN-EST-FOR-0-FREQ-P SAMPLING-TIME SCRATCH-DFT DATA-TAPER DATA-TAPER-PARAMETERS RESTORE-POWER-OPTION-P SDF-TRANSFORMATION RESULT-SDF RETURN-SDF-ESTIMATES-FOR-EACH-BLOCK-P RETURN-FREQUENCIES-P FREQ-TRANSFORMATION RESULT-FREQ

given
[1] time-series (required)
==> a vector of real-valued numbers
[2] block-size (required)
==> a power of two
[3] proportion-of-overlap (keyword; 0.5)
==> number greater than 0 and less than 1
[4] oversampling-factor (keyword; 1)
==> a factor that controls the number of frequencies
at which the wosa spectral estimate is computed;
this factor should be an integer power of two
such as 1, 2, 4, etc; for example,
1 yields Fourier frequencies for block-size;
2 yields grid twice as fine as Fourier frequencies;
4 yields griid 4 times as fine as Fourier frequencies; etc.
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series;
if nil, time-series is not centered
[6] start (keyword; 0)
==> start index of vector to be used
[7] end (keyword; length of time-series)
==> 1 + end index of vector to be used
[8] return-est-for-0-freq-p (keyword; nil)
==> if t, sdf is computed at zero frequency;
otherwise, it is not computed.
[9] sampling-time (keyword; 1.0)
==> sampling time (called delta t in the SAPA book)
[10] scratch-dft (keyword; vector of correct length)
==> vector in which the in-place dft is done
[11] data-taper (keyword; #’Hanning-data-taper!)
==> a tapering function or nil
[12] data-taper-parameters (keyword; nil)
==> parameters for tapering function (not used
if data-taper is nil); the default of nil
is appropriate for the Hanning data taper
because it does not have any parameters
[13] restore-power-option-p (keyword; t)
==> if t and data-taper is non-nil,
normalizes tapered series to have same
sum of squares as before tapering
[14] sdf-transformation (keyword; #’convert-to-dB)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-sdf
[15] result-sdf (keyword; vector of correct length)
<== vector into which wosa sdf estimate is placed;
it must be EXACTLY of the length dictated
by block-size, oversampling-factor and return-est-for-0-freq-p [16] return-sdf-estimates-for-each-block-p (keyword; t)
==> if t, individual spectra for each block are returned in a list; note that these spectra are untransformed
(i.e., the option sdf-transformation applies only
to the final wosa estimate)
[17] return-frequencies-p (keyword; t)
==> if t, the frequencies associated with the spectral estimate are computed and returned in result-freq
[18] freq-transformation (keyword; nil)
==> a function of one argument or nil;
if bound to a function, the function is used
to transform all elements of result-freq
(ignored unless return-frequencies-p is true)
[19] result-freq (keyword; nil or vector of correct length)
<== not used if return-frequencies-p nil; otherwise,
vector of length dictated by
block-size, oversampling-factor and return-est-for-0-freq-p into which the frequencies associated with the values
in result-sdf are placed
returns
[1] wosa spectral estimate
[2] associated frequencies
[3] equivalent degrees of freedom
[4] list of individual direct spectral estimates

Package

sapa

Source

nonparametric.lisp (file)

Function: x*y X Y

given
[1] x (required)
==> a sequence of numbers
[2] y (required)
==> a sequence of numbers
returns
[1] a vector of numbers obtained by multiplying corresponding elements of x and y

Package

sapa

Source

utilities.lisp (file)

Function: x*y! X Y &key RESULT

given
[1] x (required)
==> a sequence of numbers
[2] y (required)
==> a sequence of numbers
[3] result (keyword; x)
<== a sequence of numbers
returns
[1] a sequence of numbers obtained by multiplying corresponding elements of x and y

Package

sapa

Source

utilities.lisp (file)

Function: x+b X B

given
[1] x (required)
==> a sequence of numbers
[2] b (required)
==> a number
returns
[1] a vector of numbers obtained by adding b to each element of x

Package

sapa

Source

utilities.lisp (file)

Function: x+b! X B &key RESULT

given
[1] x (required)
==> a sequence of numbers
[2] b (required)
==> a number
[3] result (keyword; x)
<== a sequence of numbers
returns
[1] a sequence of numbers obtained by adding b to each element of x

Package

sapa

Source

utilities.lisp (file)

Function: x+y X Y

given
[1] x (required)
==> a sequence of numbers
[2] y (required)
==> a sequence of numbers
returns
[1] a vector of numbers obtained by adding x and y together element by element

Package

sapa

Source

utilities.lisp (file)

Function: x+y! X Y &key RESULT

given
[1] x (required)
==> a sequence of numbers
[2] y (required)
==> a sequence of numbers
[3] result (keyword; x)
<== a sequence of numbers
returns
[1] a sequence of numbers obtained by adding x and y together element by element

Package

sapa

Source

utilities.lisp (file)

Function: x-y X Y

given
[1] x (required)
==> a sequence of numbers
[2] y (required)
==> a sequence of numbers
returns
[1] a vector of numbers obtained by subtracting elements of y from corresponding elements of x

Package

sapa

Source

utilities.lisp (file)

Function: x-y! X Y &key RESULT

given
[1] x (required)
==> a sequence of numbers
[2] y (required)
==> a sequence of numbers
[3] result (keyword; x)
<== a sequence of numbers
returns
[1] a sequence of numbers obtained by subtracting elements of y from corresponding elements of x

Package

sapa

Source

utilities.lisp (file)

Function: yule-walker-algorithm-given-acvs ACVS P &key AR-COEFFS APPROXIMATE-MSES REFLECTION-COEFFS

given
[1] acvs (required)
==> a vector containing values of the acvs
for a real-valued time series x_t
from lag 0 up to (and including) p
[2] p (required)
==> autoregressive model order;
p should be an integer > 0 and < end - start
[3] AR-coeffs (keyword; a vector of length p)
<== estimates of AR coefficients phi_{1,p}, ..., phi_{p,p}
[4] approximate-MSEs (keyword; a vector of length p+1)
<== estimates of innovations variance (mean square errors)
for models of order 0, 1, ..., p (the innovations variance for the zeroth order model is the sample variance)
[5] reflection-coeffs (keyword; a vector of length p)
<== estimates of reflection coefficients phi_{1,1}, ..., phi_{p,p} uses the Yule-Walker method to estimate the phi’s in the model
x_t = phi_{1,p} x_{t-1} + ... + phi_{p,p} x_{t-p} + e_t
and returns
[1] AR-coeffs, a vector containing phi_{1,p}, ..., phi_{p,p}
[2] estimate of the innovations variance, i.e.,
the variance of the e_t’s; this number is also given in
(elt approximate-MSEs p)
[3] approximate-MSEs
[4] reflection-coeffs

Note: see Sections 9.3 and 9.4 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: yule-walker-algorithm-given-data TIME-SERIES P &key START END CENTER-DATA AR-COEFFS APPROXIMATE-MSES REFLECTION-COEFFS FORWARD-PREDICTION-ERRORS BACKWARD-PREDICTION-ERRORS

given
[1] time-series (required)
==> a vector containing a real-valued time series x_t
[2] p (required)
==> autoregressive model order;
p should be an integer > 0 and < end - start
[3] start (keyword; 0)
==> start index of vector to be used
[4] end (keyword; length of the-seq)
==> 1 + end index of vector to be used
[5] center-data (keyword; t)
==> if t, subtract sample mean from time series;
if a number, subtracts that number from time series;
if nil, the effect of this function is to return
a copy of the relevant portion of time-series
[6] AR-coeffs (keyword; a vector of length p)
<== estimates of AR coefficients phi_{1,p}, ..., phi_{p,p}
[7] approximate-MSEs (keyword; a vector of length p+1)
<== estimates of innovations variance (mean square errors)
for models of order 0, 1, ..., p (the innovations variance
for the zeroth order model is the sample variance)
[8] reflection-coeffs (keyword; a vector of length p)
<== estimates of reflection coefficients phi_{1,1}, ..., phi_{p,p} [9] forward-prediction-errors (keyword; a vector of length end - start - p) <== computed forward prediction errors
[10] backward-prediction-errors (keyword; a vector of length end - start - p) <== computed backward prediction errors
uses the Yule-Walker method to estimate the phi’s in the model
x_t = phi_{1,p} x_{t-1} + ... + phi_{p,p} x_{t-p} + e_t
and returns
[1] AR-coeffs, a vector containing phi_{1,p}, ..., phi_{p,p}
[2] estimate of the innovations variance, i.e.,
the variance of the e_t’s; this number is also given in
(elt approximate-MSEs p)
[3] approximate-MSEs
[4] reflection-coeffs
[5] forward-prediction-errors
[6] backward-prediction-errors

Note: see p. 420 of the SAPA book

Package

sapa

Source

parametric.lisp (file)

Function: zero-strict-lower-diagonal! A-MATRIX

given a square matrix,
zeros its lower diagonal and returns the modified square matrix

Package

sapa

Source

matrix.lisp (file)

Function: zeros-of-polynomial POLYNOMIAL &key DEGREE-OF-POLYNOMIAL THE-ROOTS MAXIMUM-NUMBER-OF-ITERATIONS

given
[1] polynomial (required)
==> sequence with coefficients of a polynomial;
(elt polynomial 0) must be nonzero
[2] degree-of-polynomial (keyword; (1- (length polynomial))) ==> degree of polynomial
[3] the-roots (keyword; array of length degree-of-polynomial) <== number of derivatives to be evaluated
[4] maximum-number-of-iterations (keyword; 25)
==> maximum number of iterations
returns
[1] t or nil, where t indicates that all went well, whereas nil indicates that convergence did not occur at end of specificed number of iterations
[2] the-roots, a vector with the required roots
of the polynomial

Package

sapa

Source

basic-math.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

4.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

4.2.1 Constants

Constant: +euler-constant+
Package

sapa

Source

basic-math.lisp (file)

Constant: +log-pi+
Package

sapa

Source

basic-math.lisp (file)

Constant: +ppchi2-aa+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c1+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c10+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c11+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c12+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c13+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c14+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c15+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c16+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c17+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c18+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c19+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c2+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c20+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c21+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c22+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c23+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c24+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c25+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c26+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c27+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c28+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c29+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c3+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c30+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c31+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c32+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c33+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c34+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c35+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c36+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c37+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c38+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c4+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c5+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c6+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c7+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c8+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-c9+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-e+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-pmax+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppchi2-pmin+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-a0+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-a1+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-a2+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-a3+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-b1+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-b2+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-b3+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-b4+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-c0+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-c1+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-c2+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-c3+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-d1+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +ppnd-d2+
Package

sapa

Source

basic-statistics.lisp (file)

Constant: +sapa-10-over-log-10+
Package

sapa

Source

utilities.lisp (file)

Constant: +sapa-2-pi+
Package

sapa

Source

utilities.lisp (file)

Constant: +sapa-4-time-exp-of-1-over-4+
Package

sapa

Source

random.lisp (file)

Constant: +sapa-4-time-exp-of-minus-1-point-35+
Package

sapa

Source

random.lisp (file)

Constant: +sapa-minus-2-pi+
Package

sapa

Source

utilities.lisp (file)

Constant: +sapa-sqrt-8-over-e+
Package

sapa

Source

random.lisp (file)

Constant: +sqrt-of-two-pi+
Package

sapa

Source

basic-statistics.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

4.2.2 Special variables

Special Variable: *abscissas-32-point*
Package

sapa

Source

multitaper.lisp (file)

Special Variable: *sapa-cached-pre-fft-arrays*
Package

sapa

Source

dft-and-fft.lisp (file)

Special Variable: *weights-32-point*
Package

sapa

Source

multitaper.lisp (file)

Special Variable: +coefficents-for-log-of-gamma+
Package

sapa

Source

basic-math.lisp (file)

Special Variable: +nr-gser-eps+
Package

sapa

Source

basic-statistics.lisp (file)

Special Variable: +nr-gser-itmax+
Package

sapa

Source

basic-statistics.lisp (file)

Special Variable: +use-pre-fft-with-cache-p+
Package

sapa

Source

dft-and-fft.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

4.2.3 Functions

Function: absolute-sum-of-vector-elements VECTOR
Package

sapa

Source

parametric.lisp (file)

Function: as-111 P

adapted from AS 111 — FORTRAN routine ppnd

Package

sapa

Source

basic-statistics.lisp (file)

Function: as-91 P DEGREES-OF-FREEDOM
Package

sapa

Source

basic-statistics.lisp (file)

Function: as-91-block-1 CH A G C
Package

sapa

Source

basic-statistics.lisp (file)

Function: as-91-block-4 CH XX C P G
Package

sapa

Source

basic-statistics.lisp (file)

Function: bessi0-nr X
Package

sapa

Source

tapers.lisp (file)

Function: binary-search-internal VALUE ORDERED-SEQ START END LOWER-TEST UPPER-TEST
Package

sapa

Source

utilities.lisp (file)

Function: calculate-number-of-blocks SAMPLE-SIZE BLOCK-SIZE PROPORTION-OF-OVERLAP
Package

sapa

Source

nonparametric.lisp (file)

Function: complex-of-absolutes Z
Package

sapa

Source

basic-math.lisp (file)

Function: continued-fraction-representation-for-incomplete-gamma A X
Package

sapa

Source

basic-statistics.lisp (file)

Function: dpss->eigenvalue DPSS NW

given dpss (a vector of length N) and NW, computes the corresponding eigenvalue using the method of Exercise [8.1], page 390, of the SAPA book

Package

sapa

Source

multitaper.lisp (file)

Function: eigenvalues-and-vectors-of-sym-tridiag-matrix DIAG OFF-DIAG &key MAXIMUM-NUMBER-OF-ITERATIONS RETURN-EIGENVECTORS-P Z

given
[1] diag (required)
==> sequence of diagonal elements
(length of, say, n)
[2] off-diag (required)
==> sequence of off-diagonal elements
(length of n-1)
[3] maximum-number-of-iterations (keyword; 30)
==> maximum number of iterations
[4] return-eigenvectors-p (keyword; t)
==> if true, returns eigenvalues and eigenvectors; if nil, just do the eigenvalues (this is faster) [5] z (keyword; n by n diagonal matrix)
==> usually bound to output from Householder-reduction-of-real-sym-matrix returns
[1] vector with n eigenvalues
(NOT necessarily ordered by size)
[2] if return-eigenvectors-p is true, an n by n array whose jth column is the eigenvector corresponding to the jth eigenvalue; if return-eigenvectors-p is nil, that’s what you get!

This is based upon tqli in Numerical Recipes

Package

sapa

Source

multitaper.lisp (file)

Function: equivalent-dof-for-wosa N N_S N_B VECTOR-WITH-DATA-TAPER

given the sample size N, the block size N_S, the number of blocks N_B, and the values of the data taper,
returns the equivalent degrees of freedom for wosa
using Equation (292b) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: equivalent-dof-for-wosa-standard-case N_S

given number of blocks N_S,
returns the equivalent degrees of freedom for wosa with 50% overlap and Hanning data taper
using Equation (294) of the SAPA book

Package

sapa

Source

nonparametric.lisp (file)

Function: eval-poly-2 POLYNOMIAL X
Package

sapa

Source

parametric.lisp (file)

Function: fast-tridiag-eigenvalue->dpss! EIGENVALUE ORDER-OF-TAPER DIAG OFF-DIAG &key EPS MAXIMUM-NUMBER-OF-ITERATIONS B
Package

sapa

Source

multitaper.lisp (file)

Function: find-symmetric-frequency F_1 F_2 F_3 F_N
Package

sapa

Source

parametric.lisp (file)

Function: flip-sign-of-coefficients! A-SEQUENCE
Package

sapa

Source

parametric.lisp (file)

Function: generate-initial-guess-at-dpss N ORDER-OF-TAPER &key HALF-SIZE-P RESULT
Package

sapa

Source

multitaper.lisp (file)

Function: generate-tri-prolate-taper N GENERATING-FUNCTION
Package

sapa

Source

multitaper.lisp (file)

Function: get-n-dft N-NONZERO-FREQS SAMPLE-SIZE
Package

sapa

Source

nonparametric.lisp (file)

Function: get-n-freqs N-NONZERO-FREQS SAMPLE-SIZE RETURN-EST-FOR-0-FREQ-P
Package

sapa

Source

nonparametric.lisp (file)

Function: get-offset-to-kth-block SAMPLE-SIZE BLOCK-SIZE NUMBER-OF-BLOCKS K
Package

sapa

Source

nonparametric.lisp (file)

Function: h-func F G X
Package

sapa

Source

parametric.lisp (file)

Function: householder-reduction-of-real-sym-matrix! REAL-SYM-MATRIX &key PREPARE-FOR-EIGENVECTORS-P

given
[1] real-sym-matrix (required)
==> real, symmetric matrix (n by n)
[2] prepare-for-eigenvectors-p (keyword; t)
==> if true, crunch real-sym-matrix for use with eigenvalues-and-vectors-of-sym-tridiag-matrix returns
[1] n-dimensional vector with diagonal elements of associated tridiagonal matrix
[2] (n-1)-dimensional vector with off-diagonal elements of associated tridiagonal matrix

See tred2 in Numerical Recipes

Package

sapa

Source

multitaper.lisp (file)

Function: incomplete-gamma A X

arguments:
a — parameter value > 0
x — variable >= 0
returns three values:
value of incomplete gamma function at a and x; the numerator (little gamma of a and x); the denominator (gamma of a);
see Section 6.2 of NR

Package

sapa

Source

basic-statistics.lisp (file)

Function: incomplete-gamma-q A X

arguments:
a — parameter value > 0
x — variable >= 0
returns three values:
value of incomplete gamma function at a and x; the numerator (big gamma of a and x);
the denominator (gamma of a);
see Section 6.2 of NR

Package

sapa

Source

basic-statistics.lisp (file)

Function: initial-estimates-for-zeros-of-polynomial POLYNOMIAL &key DEGREE-OF-POLYNOMIAL INITIAL-ESTIMATES SCRATCH
Package

sapa

Source

basic-math.lisp (file)

Function: kth-eigenvalue-of-tridiagonal-matrix DIAG OFF-DIAG K &key SQUARED-OFF-DIAG MACHEPS
Package

sapa

Source

multitaper.lisp (file)

Function: largest-eigenvalues-of-tridiagonal-matrix DIAG OFF-DIAG NUMBER-OF-TAPERS &key SQUARED-OFF-DIAG MACHEPS PRINT-PROGRESS-P
Package

sapa

Source

multitaper.lisp (file)

Function: one-iteration-of-two-step-burg K STEP N FK BK PHI LIMIT
Package

sapa

Source

parametric.lisp (file)

Function: power-of-2+1 N
Package

sapa

Source

utilities.lisp (file)

Function: pre-fft N &key COMPLEX-EXP-VECTOR
Package

sapa

Source

dft-and-fft.lisp (file)

Function: pre-fft-with-cache N
Package

sapa

Source

dft-and-fft.lisp (file)

Function: produce-upsilon-func COEFFICIENTS
Package

sapa

Source

multitaper.lisp (file)

Function: series-representation-for-incomplete-gamma A X
Package

sapa

Source

basic-statistics.lisp (file)

Function: sturm-sequence-count TEST-LAMBDA DIAG OFF-DIAG SQUARED-OFF-DIAG MACHEP &key START END
Package

sapa

Source

multitaper.lisp (file)

Function: symmetric-tridiagonal-infinity-norm DIAG OFF-DIAG
Package

sapa

Source

multitaper.lisp (file)

Function: symmetric-tridiagonal-solve! DIAG OFF-DIAG B

given
[1] diag (required)
<=> diagonal part of symmetric tridiagonal matrix A; trash on output
[1] off-diag (required)
<=> off-diagonal part of symmetric tridiagonal matrix; trash on output
[2] b (required)
<=> on input, the right-hand side vector;
on output, the solution X to A X = b
returns
[4] X, the solution to A X = b, where X is the vector that contained b on input

Note: this is an implementation of Algorithm 4.3.6,
p. 156, Golub and Van Loan, 1989, with modifications
to avoid divides by zero

Package

sapa

Source

multitaper.lisp (file)

Function: toeplitz R Y &optional X

given
[1] r (required)
==> vector of length 2*N-1 representing
the Toeplitz matrix R(i,j) with 0 <= i,j <= N-1, via the 2*N-1 values
r(0,N-1), r(0,N-2),..., r(0,1),
r(0,0), r(1,0),..., r(N-1,0)
[2] y (required)
==> right-hand side vector of length N
[3] x (optional; vector of same size as y)
<== solution vector of length N
solves the Toeplitz system sum_{j=0}^{N-1} r_{N-1+i-j} x_j = y_j for i = 0, 1, ..., N-1 and
returns
[1] x (a vector of length N)
or
nil (in case of a failure of the Levinson method
due to a singular principal minor

Note: this function is essentially a Lisp version
of the Fortran routine toeplz from Numerical Recipes

Package

sapa

Source

multitaper.lisp (file)

Function: trapezoidal-rule F A B S N
Package

sapa

Source

basic-math.lisp (file)

Function: tridiag-eigenvalue->dpss! EIGENVALUE ORDER-OF-TAPER DIAG OFF-DIAG &key EPS MAXIMUM-NUMBER-OF-ITERATIONS B
Package

sapa

Source

multitaper.lisp (file)

Function: trig-prolate-sign-cosine-coefficients M K
Package

sapa

Source

multitaper.lisp (file)

Function: which-is-faster? N-FILTER N-TS
Package

sapa

Source

filtering.lisp (file)

Function: wosa-get-n-freqs BLOCK-SIZE OVERSAMPLING-FACTOR RETURN-EST-FOR-0-FREQ-P
Package

sapa

Source

nonparametric.lisp (file)

Function: zeros-of-polynomial-with-initial-estimates POLYNOMIAL INITIAL-ESTIMATES &key DEGREE-OF-POLYNOMIAL SCRATCH FINAL-RESULTS MAXIMUM-NUMBER-OF-ITERATIONS
Package

sapa

Source

basic-math.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   S  
Index Entry  Section

F
File, Lisp, sapaclisp.asd: The sapaclisp<dot>asd file
File, Lisp, sapaclisp/acvs.lisp: The sapaclisp/acvs<dot>lisp file
File, Lisp, sapaclisp/basic-math.lisp: The sapaclisp/basic-math<dot>lisp file
File, Lisp, sapaclisp/basic-statistics.lisp: The sapaclisp/basic-statistics<dot>lisp file
File, Lisp, sapaclisp/dft-and-fft.lisp: The sapaclisp/dft-and-fft<dot>lisp file
File, Lisp, sapaclisp/filtering.lisp: The sapaclisp/filtering<dot>lisp file
File, Lisp, sapaclisp/hacks.lisp: The sapaclisp/hacks<dot>lisp file
File, Lisp, sapaclisp/harmonic.lisp: The sapaclisp/harmonic<dot>lisp file
File, Lisp, sapaclisp/matrix.lisp: The sapaclisp/matrix<dot>lisp file
File, Lisp, sapaclisp/multitaper.lisp: The sapaclisp/multitaper<dot>lisp file
File, Lisp, sapaclisp/nonparametric.lisp: The sapaclisp/nonparametric<dot>lisp file
File, Lisp, sapaclisp/parametric.lisp: The sapaclisp/parametric<dot>lisp file
File, Lisp, sapaclisp/random.lisp: The sapaclisp/random<dot>lisp file
File, Lisp, sapaclisp/sapa-package.lisp: The sapaclisp/sapa-package<dot>lisp file
File, Lisp, sapaclisp/tapers.lisp: The sapaclisp/tapers<dot>lisp file
File, Lisp, sapaclisp/utilities.lisp: The sapaclisp/utilities<dot>lisp file

L
Lisp File, sapaclisp.asd: The sapaclisp<dot>asd file
Lisp File, sapaclisp/acvs.lisp: The sapaclisp/acvs<dot>lisp file
Lisp File, sapaclisp/basic-math.lisp: The sapaclisp/basic-math<dot>lisp file
Lisp File, sapaclisp/basic-statistics.lisp: The sapaclisp/basic-statistics<dot>lisp file
Lisp File, sapaclisp/dft-and-fft.lisp: The sapaclisp/dft-and-fft<dot>lisp file
Lisp File, sapaclisp/filtering.lisp: The sapaclisp/filtering<dot>lisp file
Lisp File, sapaclisp/hacks.lisp: The sapaclisp/hacks<dot>lisp file
Lisp File, sapaclisp/harmonic.lisp: The sapaclisp/harmonic<dot>lisp file
Lisp File, sapaclisp/matrix.lisp: The sapaclisp/matrix<dot>lisp file
Lisp File, sapaclisp/multitaper.lisp: The sapaclisp/multitaper<dot>lisp file
Lisp File, sapaclisp/nonparametric.lisp: The sapaclisp/nonparametric<dot>lisp file
Lisp File, sapaclisp/parametric.lisp: The sapaclisp/parametric<dot>lisp file
Lisp File, sapaclisp/random.lisp: The sapaclisp/random<dot>lisp file
Lisp File, sapaclisp/sapa-package.lisp: The sapaclisp/sapa-package<dot>lisp file
Lisp File, sapaclisp/tapers.lisp: The sapaclisp/tapers<dot>lisp file
Lisp File, sapaclisp/utilities.lisp: The sapaclisp/utilities<dot>lisp file

S
sapaclisp.asd: The sapaclisp<dot>asd file
sapaclisp/acvs.lisp: The sapaclisp/acvs<dot>lisp file
sapaclisp/basic-math.lisp: The sapaclisp/basic-math<dot>lisp file
sapaclisp/basic-statistics.lisp: The sapaclisp/basic-statistics<dot>lisp file
sapaclisp/dft-and-fft.lisp: The sapaclisp/dft-and-fft<dot>lisp file
sapaclisp/filtering.lisp: The sapaclisp/filtering<dot>lisp file
sapaclisp/hacks.lisp: The sapaclisp/hacks<dot>lisp file
sapaclisp/harmonic.lisp: The sapaclisp/harmonic<dot>lisp file
sapaclisp/matrix.lisp: The sapaclisp/matrix<dot>lisp file
sapaclisp/multitaper.lisp: The sapaclisp/multitaper<dot>lisp file
sapaclisp/nonparametric.lisp: The sapaclisp/nonparametric<dot>lisp file
sapaclisp/parametric.lisp: The sapaclisp/parametric<dot>lisp file
sapaclisp/random.lisp: The sapaclisp/random<dot>lisp file
sapaclisp/sapa-package.lisp: The sapaclisp/sapa-package<dot>lisp file
sapaclisp/tapers.lisp: The sapaclisp/tapers<dot>lisp file
sapaclisp/utilities.lisp: The sapaclisp/utilities<dot>lisp file

Jump to:   F   L   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   2  
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z  
Index Entry  Section

2
2d-matrix->linearized-upper-trangular: Exported functions
2d-matrix-move!: Exported functions

A
a*x: Exported functions
a*x!: Exported functions
a*x+b: Exported functions
a*x+b!: Exported functions
a*x+y: Exported functions
a*x+y!: Exported functions
absolute-sum-of-vector-elements: Internal functions
acvs: Exported functions
acvs-for-time-series-simulated-from-sdf: Exported functions
add-sequences: Exported functions
ar-coeffs->acvs: Exported functions
ar-coeffs->prewhitening-filter: Exported functions
ar-coeffs->reflection-coeffs: Exported functions
ar-coeffs->sdf: Exported functions
ar-coeffs->sdf-at-single-freq: Exported functions
ar-coeffs->variance: Exported functions
as-111: Internal functions
as-91: Internal functions
as-91-block-1: Internal functions
as-91-block-4: Internal functions

B
bandwidth&confidence-intervals-for-sdf-db: Exported functions
bartlett-bandwidth->m: Exported functions
bartlett-lag-window: Exported functions
bartlett-m->bandwidth: Exported functions
bartlett-n-m->degrees-of-freedom: Exported functions
bessi0-nr: Internal functions
biased-acvs->unbiased-acvs: Exported functions
binary-search: Exported functions
binary-search-internal: Internal functions
bisection-with-newton-raphson: Exported functions
box-plot: Exported functions
burg-algorithm: Exported functions

C
calculate-number-of-blocks: Internal functions
careful-convert-to-db: Exported functions
center&prewhiten&taper-time-series: Exported functions
center&taper-time-series: Exported functions
cepstrum->i_m: Exported functions
check-orthonormality: Exported functions
cholesky!: Exported functions
circular-shift-sequence: Exported functions
compare-seqs: Exported functions
complex-of-absolutes: Internal functions
compose-symmetric-filters: Exported functions
continued-fraction-representation-for-incomplete-gamma: Internal functions
convert-from-db: Exported functions
convert-to-db: Exported functions
copy-vector: Exported functions
cosine-data-taper!: Exported functions
create-ci-for-amt-sdf-estimate: Exported functions
create-dpss-low-pass-filter: Exported functions
create-least-squares-low-pass-filter: Exported functions
cumulative-periodogram: Exported functions
cumulative-sums: Exported functions

D
daniell-bandwidth->m: Exported functions
daniell-lag-window: Exported functions
daniell-m->bandwidth: Exported functions
daniell-n-m->degrees-of-freedom: Exported functions
dft!: Exported functions
dft-chirp!: Exported functions
difference: Exported functions
digamma: Exported functions
direct-spectral-estimate: Exported functions
divf: Exported macros
dot-product: Exported functions
dpss->eigenvalue: Internal functions
dpss-data-taper!: Exported functions
dpss-tapers-inverse-iteration: Exported functions
dpss-tapers-thomson-approx: Exported functions
dpss-tapers-tri-diag: Exported functions
durbin-watson-test-statistic: Exported functions

E
eigenspectra->adaptive-multitaper-spectral-estimate: Exported functions
eigenspectra->multitaper-spectral-estimate: Exported functions
eigenvalues-and-vectors-of-sym-tridiag-matrix: Internal functions
equivalent-degrees-of-freedom: Exported functions
equivalent-dof-for-wosa: Internal functions
equivalent-dof-for-wosa-standard-case: Internal functions
euclidean-norm: Exported functions
eval-poly-2: Internal functions
evaluate-polynomial: Exported functions
exponential-smoothing: Exported functions

F
factorial: Exported functions
fast-forward-backward-ls: Exported functions
fast-tridiag-eigenvalue->dpss!: Internal functions
fft!: Exported functions
filter-time-series: Exported functions
filter-time-series-direct: Exported functions
filter-time-series-fft: Exported functions
find-peak-of-ar-sdf-using-quadratic-approx: Exported functions
find-peak-or-valley-of-sdf-using-bisection+newton-raphson: Exported functions
find-symmetric-frequency: Internal functions
fisher-g-statistic: Exported functions
flip-sign-of-coefficients!: Internal functions
forward-backward-ls: Exported functions
forward-ls: Exported functions
Function, 2d-matrix->linearized-upper-trangular: Exported functions
Function, 2d-matrix-move!: Exported functions
Function, a*x: Exported functions
Function, a*x!: Exported functions
Function, a*x+b: Exported functions
Function, a*x+b!: Exported functions
Function, a*x+y: Exported functions
Function, a*x+y!: Exported functions
Function, absolute-sum-of-vector-elements: Internal functions
Function, acvs: Exported functions
Function, acvs-for-time-series-simulated-from-sdf: Exported functions
Function, add-sequences: Exported functions
Function, ar-coeffs->acvs: Exported functions
Function, ar-coeffs->prewhitening-filter: Exported functions
Function, ar-coeffs->reflection-coeffs: Exported functions
Function, ar-coeffs->sdf: Exported functions
Function, ar-coeffs->sdf-at-single-freq: Exported functions
Function, ar-coeffs->variance: Exported functions
Function, as-111: Internal functions
Function, as-91: Internal functions
Function, as-91-block-1: Internal functions
Function, as-91-block-4: Internal functions
Function, bandwidth&confidence-intervals-for-sdf-db: Exported functions
Function, bartlett-bandwidth->m: Exported functions
Function, bartlett-lag-window: Exported functions
Function, bartlett-m->bandwidth: Exported functions
Function, bartlett-n-m->degrees-of-freedom: Exported functions
Function, bessi0-nr: Internal functions
Function, biased-acvs->unbiased-acvs: Exported functions
Function, binary-search: Exported functions
Function, binary-search-internal: Internal functions
Function, bisection-with-newton-raphson: Exported functions
Function, box-plot: Exported functions
Function, burg-algorithm: Exported functions
Function, calculate-number-of-blocks: Internal functions
Function, careful-convert-to-db: Exported functions
Function, center&prewhiten&taper-time-series: Exported functions
Function, center&taper-time-series: Exported functions
Function, cepstrum->i_m: Exported functions
Function, check-orthonormality: Exported functions
Function, cholesky!: Exported functions
Function, circular-shift-sequence: Exported functions
Function, compare-seqs: Exported functions
Function, complex-of-absolutes: Internal functions
Function, compose-symmetric-filters: Exported functions
Function, continued-fraction-representation-for-incomplete-gamma: Internal functions
Function, convert-from-db: Exported functions
Function, convert-to-db: Exported functions
Function, copy-vector: Exported functions
Function, cosine-data-taper!: Exported functions
Function, create-ci-for-amt-sdf-estimate: Exported functions
Function, create-dpss-low-pass-filter: Exported functions
Function, create-least-squares-low-pass-filter: Exported functions
Function, cumulative-periodogram: Exported functions
Function, cumulative-sums: Exported functions
Function, daniell-bandwidth->m: Exported functions
Function, daniell-lag-window: Exported functions
Function, daniell-m->bandwidth: Exported functions
Function, daniell-n-m->degrees-of-freedom: Exported functions
Function, dft!: Exported functions
Function, dft-chirp!: Exported functions
Function, difference: Exported functions
Function, digamma: Exported functions
Function, direct-spectral-estimate: Exported functions
Function, dot-product: Exported functions
Function, dpss->eigenvalue: Internal functions
Function, dpss-data-taper!: Exported functions
Function, dpss-tapers-inverse-iteration: Exported functions
Function, dpss-tapers-thomson-approx: Exported functions
Function, dpss-tapers-tri-diag: Exported functions
Function, durbin-watson-test-statistic: Exported functions
Function, eigenspectra->adaptive-multitaper-spectral-estimate: Exported functions
Function, eigenspectra->multitaper-spectral-estimate: Exported functions
Function, eigenvalues-and-vectors-of-sym-tridiag-matrix: Internal functions
Function, equivalent-degrees-of-freedom: Exported functions
Function, equivalent-dof-for-wosa: Internal functions
Function, equivalent-dof-for-wosa-standard-case: Internal functions
Function, euclidean-norm: Exported functions
Function, eval-poly-2: Internal functions
Function, evaluate-polynomial: Exported functions
Function, exponential-smoothing: Exported functions
Function, factorial: Exported functions
Function, fast-forward-backward-ls: Exported functions
Function, fast-tridiag-eigenvalue->dpss!: Internal functions
Function, fft!: Exported functions
Function, filter-time-series: Exported functions
Function, filter-time-series-direct: Exported functions
Function, filter-time-series-fft: Exported functions
Function, find-peak-of-ar-sdf-using-quadratic-approx: Exported functions
Function, find-peak-or-valley-of-sdf-using-bisection+newton-raphson: Exported functions
Function, find-symmetric-frequency: Internal functions
Function, fisher-g-statistic: Exported functions
Function, flip-sign-of-coefficients!: Internal functions
Function, forward-backward-ls: Exported functions
Function, forward-ls: Exported functions
Function, gauss-legendre-quadrature: Exported functions
Function, generate-ar-time-series: Exported functions
Function, generate-backward-innovations: Exported functions
Function, generate-forward-innovations: Exported functions
Function, generate-initial-guess-at-dpss: Internal functions
Function, generate-ma-time-series: Exported functions
Function, generate-tri-prolate-taper: Internal functions
Function, generate-white-noise: Exported functions
Function, get-n-dft: Internal functions
Function, get-n-freqs: Internal functions
Function, get-offset-to-kth-block: Internal functions
Function, grenander-smoothing-window-bandwidth: Exported functions
Function, h-func: Internal functions
Function, hanning-data-taper!: Exported functions
Function, hermitian-transpose: Exported functions
Function, histogram: Exported functions
Function, householder-reduction-of-real-sym-matrix!: Internal functions
Function, huber-weight-function: Exported functions
Function, ideal-band-pass-filter-irs: Exported functions
Function, ideal-high-pass-filter-irs: Exported functions
Function, ideal-low-pass-filter-irs: Exported functions
Function, incomplete-gamma: Internal functions
Function, incomplete-gamma-q: Internal functions
Function, initial-estimates-for-zeros-of-polynomial: Internal functions
Function, integrate-sdf: Exported functions
Function, interquartile-range: Exported functions
Function, inverse-dft!: Exported functions
Function, inverse-fft!: Exported functions
Function, iota: Exported functions
Function, jenkins-smoothing-window-bandwidth: Exported functions
Function, kernel-pdf-estimation: Exported functions
Function, kth-eigenvalue-of-tridiagonal-matrix: Internal functions
Function, lag-window-spectral-estimate: Exported functions
Function, largest-eigenvalues-of-tridiagonal-matrix: Internal functions
Function, linear-interpolation!: Exported functions
Function, linearized-upper-trangular->2d-matrix: Exported functions
Function, log-of-gamma: Exported functions
Function, log10: Exported functions
Function, lower-triangular-solve!: Exported functions
Function, m-location-estimate: Exported functions
Function, max-of-seq: Exported functions
Function, median-absolute-deviation: Exported functions
Function, min-and-max-of-seq: Exported functions
Function, min-of-seq: Exported functions
Function, modified-gram-schmidt!: Exported functions
Function, multiply-2-polynomials: Exported functions
Function, multiply-matrix-and-scalar: Exported functions
Function, multiply-matrix-and-vector: Exported functions
Function, multiply-polynomials: Exported functions
Function, multiply-sequences: Exported functions
Function, multiply-two-matrices: Exported functions
Function, multitaper-spectral-estimate: Exported functions
Function, n-applications-of-three-point-smoother: Exported functions
Function, newton-raphson: Exported functions
Function, next-power-of-2: Exported functions
Function, nyquist-frequency->sampling-time: Exported functions
Function, one-iteration-of-two-step-burg: Internal functions
Function, one-sided-freq->two-sided-freq: Exported functions
Function, one-sided-sdf->two-sided-sdf: Exported functions
Function, ordinary-least-squares-cholesky: Exported functions
Function, ordinary-least-squares-q-r: Exported functions
Function, papoulis-bandwidth->m: Exported functions
Function, papoulis-lag-window: Exported functions
Function, papoulis-m->bandwidth: Exported functions
Function, papoulis-n-m->degrees-of-freedom: Exported functions
Function, parzen-bandwidth->m: Exported functions
Function, parzen-lag-window: Exported functions
Function, parzen-m->bandwidth: Exported functions
Function, parzen-n-m->degrees-of-freedom: Exported functions
Function, periodogram: Exported functions
Function, periodogram-at-one-frequency: Exported functions
Function, postcolor-spectral-estimate: Exported functions
Function, power-of-2: Exported functions
Function, power-of-2+1: Internal functions
Function, pre-fft: Internal functions
Function, pre-fft-with-cache: Internal functions
Function, predicted-y-at-x: Exported functions
Function, print-1-or-2-d-array: Exported functions
Function, print-rows-of-nxm-matrix: Exported functions
Function, produce-upsilon-func: Internal functions
Function, q-q-plot: Exported functions
Function, q-r!: Exported functions
Function, quantile-of-chi-square-2-distribution: Exported functions
Function, quantile-of-chi-square-distribution: Exported functions
Function, quantile-of-exponential-distribution: Exported functions
Function, quantile-of-gamma-distribution: Exported functions
Function, quantile-of-kolmogorov-test-statistic: Exported functions
Function, quantile-of-normal-distribution: Exported functions
Function, quantile-of-ordered-seq: Exported functions
Function, quantile-plot: Exported functions
Function, ranorm: Exported functions
Function, ranorms: Exported functions
Function, reflection-coeffs->ar-coeffs: Exported functions
Function, reflection-coeffs->variance: Exported functions
Function, regression-with-ar-errors: Exported functions
Function, running-median: Exported functions
Function, sample-cepstrum: Exported functions
Function, sample-correlation-coefficient: Exported functions
Function, sample-from-a-function: Exported functions
Function, sample-mean: Exported functions
Function, sample-mean-and-variance: Exported functions
Function, sample-median: Exported functions
Function, sample-skewness-and-kurtosis: Exported functions
Function, sample-variance: Exported functions
Function, sample-variogram: Exported functions
Function, sampling-time->nyquist-frequency: Exported functions
Function, sdf->sdf-with-accurate-peaks: Exported functions
Function, secant-method: Exported functions
Function, series-representation-for-incomplete-gamma: Internal functions
Function, sign: Exported functions
Function, simple-numerical-integration: Exported functions
Function, simulate-time-series-from-sdf: Exported functions
Function, smoothing-window-for-lag-window-spectral-estimate: Exported functions
Function, spectral-window-for-direct-spectral-estimate: Exported functions
Function, spectral-window-for-lag-window-spectral-estimate: Exported functions
Function, spofa!: Exported functions
Function, sposl!: Exported functions
Function, standard-normal-pdf: Exported functions
Function, step-down-levinson-durbin-recursions: Exported functions
Function, sturm-sequence-count: Internal functions
Function, subtract-two-matrices: Exported functions
Function, sum: Exported functions
Function, sum-of-squares: Exported functions
Function, supplied-data-taper!: Exported functions
Function, symmetric-tridiagonal-infinity-norm: Internal functions
Function, symmetric-tridiagonal-solve!: Internal functions
Function, symmetry-plot: Exported functions
Function, tail-area-of-normal-distribution: Exported functions
Function, thomson-weight-function: Exported functions
Function, three-point-smoother: Exported functions
Function, time-series-bandwidth: Exported functions
Function, toeplitz: Internal functions
Function, trace-matrix: Exported functions
Function, transfer-function-for-filter: Exported functions
Function, transform-a-sequence: Exported functions
Function, transform-a-sequence!: Exported functions
Function, transpose: Exported functions
Function, trapezoidal-rule: Internal functions
Function, triangular-convergence-factors: Exported functions
Function, tridiag-eigenvalue->dpss!: Internal functions
Function, trig-prolate-sign-cosine-coefficients: Internal functions
Function, trig-prolate-tapers: Exported functions
Function, trigamma: Exported functions
Function, two-step-burg-algorithm: Exported functions
Function, upper-triangular-solve!: Exported functions
Function, var-predicted-mean-at-x: Exported functions
Function, var-predicted-y-at-x: Exported functions
Function, weighted-linear-least-squares: Exported functions
Function, weighted-mean: Exported functions
Function, which-is-faster?: Internal functions
Function, window-width-from-silverman: Exported functions
Function, wosa-get-n-freqs: Internal functions
Function, wosa-spectral-estimate: Exported functions
Function, x*y: Exported functions
Function, x*y!: Exported functions
Function, x+b: Exported functions
Function, x+b!: Exported functions
Function, x+y: Exported functions
Function, x+y!: Exported functions
Function, x-y: Exported functions
Function, x-y!: Exported functions
Function, yule-walker-algorithm-given-acvs: Exported functions
Function, yule-walker-algorithm-given-data: Exported functions
Function, zero-strict-lower-diagonal!: Exported functions
Function, zeros-of-polynomial: Exported functions
Function, zeros-of-polynomial-with-initial-estimates: Internal functions

G
gauss-legendre-quadrature: Exported functions
generate-ar-time-series: Exported functions
generate-backward-innovations: Exported functions
generate-forward-innovations: Exported functions
generate-initial-guess-at-dpss: Internal functions
generate-ma-time-series: Exported functions
generate-tri-prolate-taper: Internal functions
generate-white-noise: Exported functions
get-n-dft: Internal functions
get-n-freqs: Internal functions
get-offset-to-kth-block: Internal functions
grenander-smoothing-window-bandwidth: Exported functions

H
h-func: Internal functions
hanning-data-taper!: Exported functions
hermitian-transpose: Exported functions
histogram: Exported functions
householder-reduction-of-real-sym-matrix!: Internal functions
huber-weight-function: Exported functions

I
ideal-band-pass-filter-irs: Exported functions
ideal-high-pass-filter-irs: Exported functions
ideal-low-pass-filter-irs: Exported functions
incomplete-gamma: Internal functions
incomplete-gamma-q: Internal functions
initial-estimates-for-zeros-of-polynomial: Internal functions
integrate-sdf: Exported functions
interquartile-range: Exported functions
inverse-dft!: Exported functions
inverse-fft!: Exported functions
iota: Exported functions

J
jenkins-smoothing-window-bandwidth: Exported functions

K
kernel-pdf-estimation: Exported functions
kth-eigenvalue-of-tridiagonal-matrix: Internal functions

L
lag-window-spectral-estimate: Exported functions
largest-eigenvalues-of-tridiagonal-matrix: Internal functions
linear-interpolation!: Exported functions
linearized-upper-trangular->2d-matrix: Exported functions
log-of-gamma: Exported functions
log10: Exported functions
lower-triangular-solve!: Exported functions

M
m-location-estimate: Exported functions
Macro, divf: Exported macros
Macro, multf: Exported macros
max-of-seq: Exported functions
median-absolute-deviation: Exported functions
min-and-max-of-seq: Exported functions
min-of-seq: Exported functions
modified-gram-schmidt!: Exported functions
multf: Exported macros
multiply-2-polynomials: Exported functions
multiply-matrix-and-scalar: Exported functions
multiply-matrix-and-vector: Exported functions
multiply-polynomials: Exported functions
multiply-sequences: Exported functions
multiply-two-matrices: Exported functions
multitaper-spectral-estimate: Exported functions

N
n-applications-of-three-point-smoother: Exported functions
newton-raphson: Exported functions
next-power-of-2: Exported functions
nyquist-frequency->sampling-time: Exported functions

O
one-iteration-of-two-step-burg: Internal functions
one-sided-freq->two-sided-freq: Exported functions
one-sided-sdf->two-sided-sdf: Exported functions
ordinary-least-squares-cholesky: Exported functions
ordinary-least-squares-q-r: Exported functions

P
papoulis-bandwidth->m: Exported functions
papoulis-lag-window: Exported functions
papoulis-m->bandwidth: Exported functions
papoulis-n-m->degrees-of-freedom: Exported functions
parzen-bandwidth->m: Exported functions
parzen-lag-window: Exported functions
parzen-m->bandwidth: Exported functions
parzen-n-m->degrees-of-freedom: Exported functions
periodogram: Exported functions
periodogram-at-one-frequency: Exported functions
postcolor-spectral-estimate: Exported functions
power-of-2: Exported functions
power-of-2+1: Internal functions
pre-fft: Internal functions
pre-fft-with-cache: Internal functions
predicted-y-at-x: Exported functions
print-1-or-2-d-array: Exported functions
print-rows-of-nxm-matrix: Exported functions
produce-upsilon-func: Internal functions

Q
q-q-plot: Exported functions
q-r!: Exported functions
quantile-of-chi-square-2-distribution: Exported functions
quantile-of-chi-square-distribution: Exported functions
quantile-of-exponential-distribution: Exported functions
quantile-of-gamma-distribution: Exported functions
quantile-of-kolmogorov-test-statistic: Exported functions
quantile-of-normal-distribution: Exported functions
quantile-of-ordered-seq: Exported functions
quantile-plot: Exported functions

R
ranorm: Exported functions
ranorms: Exported functions
reflection-coeffs->ar-coeffs: Exported functions
reflection-coeffs->variance: Exported functions
regression-with-ar-errors: Exported functions
running-median: Exported functions

S
sample-cepstrum: Exported functions
sample-correlation-coefficient: Exported functions
sample-from-a-function: Exported functions
sample-mean: Exported functions
sample-mean-and-variance: Exported functions
sample-median: Exported functions
sample-skewness-and-kurtosis: Exported functions
sample-variance: Exported functions
sample-variogram: Exported functions
sampling-time->nyquist-frequency: Exported functions
sdf->sdf-with-accurate-peaks: Exported functions
secant-method: Exported functions
series-representation-for-incomplete-gamma: Internal functions
sign: Exported functions
simple-numerical-integration: Exported functions
simulate-time-series-from-sdf: Exported functions
smoothing-window-for-lag-window-spectral-estimate: Exported functions
spectral-window-for-direct-spectral-estimate: Exported functions
spectral-window-for-lag-window-spectral-estimate: Exported functions
spofa!: Exported functions
sposl!: Exported functions
standard-normal-pdf: Exported functions
step-down-levinson-durbin-recursions: Exported functions
sturm-sequence-count: Internal functions
subtract-two-matrices: Exported functions
sum: Exported functions
sum-of-squares: Exported functions
supplied-data-taper!: Exported functions
symmetric-tridiagonal-infinity-norm: Internal functions
symmetric-tridiagonal-solve!: Internal functions
symmetry-plot: Exported functions

T
tail-area-of-normal-distribution: Exported functions
thomson-weight-function: Exported functions
three-point-smoother: Exported functions
time-series-bandwidth: Exported functions
toeplitz: Internal functions
trace-matrix: Exported functions
transfer-function-for-filter: Exported functions
transform-a-sequence: Exported functions
transform-a-sequence!: Exported functions
transpose: Exported functions
trapezoidal-rule: Internal functions
triangular-convergence-factors: Exported functions
tridiag-eigenvalue->dpss!: Internal functions
trig-prolate-sign-cosine-coefficients: Internal functions
trig-prolate-tapers: Exported functions
trigamma: Exported functions
two-step-burg-algorithm: Exported functions

U
upper-triangular-solve!: Exported functions

V
var-predicted-mean-at-x: Exported functions
var-predicted-y-at-x: Exported functions

W
weighted-linear-least-squares: Exported functions
weighted-mean: Exported functions
which-is-faster?: Internal functions
window-width-from-silverman: Exported functions
wosa-get-n-freqs: Internal functions
wosa-spectral-estimate: Exported functions

X
x*y: Exported functions
x*y!: Exported functions
x+b: Exported functions
x+b!: Exported functions
x+y: Exported functions
x+y!: Exported functions
x-y: Exported functions
x-y!: Exported functions

Y
yule-walker-algorithm-given-acvs: Exported functions
yule-walker-algorithm-given-data: Exported functions

Z
zero-strict-lower-diagonal!: Exported functions
zeros-of-polynomial: Exported functions
zeros-of-polynomial-with-initial-estimates: Internal functions

Jump to:   2  
A   B   C   D   E   F   G   H   I   J   K   L   M   N   O   P   Q   R   S   T   U   V   W   X   Y   Z  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *   +  
C   S  
Index Entry  Section

*
*abscissas-32-point*: Internal special variables
*sapa-cached-pre-fft-arrays*: Internal special variables
*weights-32-point*: Internal special variables

+
+coefficents-for-log-of-gamma+: Internal special variables
+euler-constant+: Internal constants
+log-pi+: Internal constants
+nr-gser-eps+: Internal special variables
+nr-gser-itmax+: Internal special variables
+ppchi2-aa+: Internal constants
+ppchi2-c1+: Internal constants
+ppchi2-c10+: Internal constants
+ppchi2-c11+: Internal constants
+ppchi2-c12+: Internal constants
+ppchi2-c13+: Internal constants
+ppchi2-c14+: Internal constants
+ppchi2-c15+: Internal constants
+ppchi2-c16+: Internal constants
+ppchi2-c17+: Internal constants
+ppchi2-c18+: Internal constants
+ppchi2-c19+: Internal constants
+ppchi2-c2+: Internal constants
+ppchi2-c20+: Internal constants
+ppchi2-c21+: Internal constants
+ppchi2-c22+: Internal constants
+ppchi2-c23+: Internal constants
+ppchi2-c24+: Internal constants
+ppchi2-c25+: Internal constants
+ppchi2-c26+: Internal constants
+ppchi2-c27+: Internal constants
+ppchi2-c28+: Internal constants
+ppchi2-c29+: Internal constants
+ppchi2-c3+: Internal constants
+ppchi2-c30+: Internal constants
+ppchi2-c31+: Internal constants
+ppchi2-c32+: Internal constants
+ppchi2-c33+: Internal constants
+ppchi2-c34+: Internal constants
+ppchi2-c35+: Internal constants
+ppchi2-c36+: Internal constants
+ppchi2-c37+: Internal constants
+ppchi2-c38+: Internal constants
+ppchi2-c4+: Internal constants
+ppchi2-c5+: Internal constants
+ppchi2-c6+: Internal constants
+ppchi2-c7+: Internal constants
+ppchi2-c8+: Internal constants
+ppchi2-c9+: Internal constants
+ppchi2-e+: Internal constants
+ppchi2-pmax+: Internal constants
+ppchi2-pmin+: Internal constants
+ppnd-a0+: Internal constants
+ppnd-a1+: Internal constants
+ppnd-a2+: Internal constants
+ppnd-a3+: Internal constants
+ppnd-b1+: Internal constants
+ppnd-b2+: Internal constants
+ppnd-b3+: Internal constants
+ppnd-b4+: Internal constants
+ppnd-c0+: Internal constants
+ppnd-c1+: Internal constants
+ppnd-c2+: Internal constants
+ppnd-c3+: Internal constants
+ppnd-d1+: Internal constants
+ppnd-d2+: Internal constants
+sapa-10-over-log-10+: Internal constants
+sapa-2-pi+: Internal constants
+sapa-4-time-exp-of-1-over-4+: Internal constants
+sapa-4-time-exp-of-minus-1-point-35+: Internal constants
+sapa-minus-2-pi+: Internal constants
+sapa-sqrt-8-over-e+: Internal constants
+sqrt-of-two-pi+: Internal constants
+use-pre-fft-with-cache-p+: Internal special variables

C
Constant, +euler-constant+: Internal constants
Constant, +log-pi+: Internal constants
Constant, +ppchi2-aa+: Internal constants
Constant, +ppchi2-c1+: Internal constants
Constant, +ppchi2-c10+: Internal constants
Constant, +ppchi2-c11+: Internal constants
Constant, +ppchi2-c12+: Internal constants
Constant, +ppchi2-c13+: Internal constants
Constant, +ppchi2-c14+: Internal constants
Constant, +ppchi2-c15+: Internal constants
Constant, +ppchi2-c16+: Internal constants
Constant, +ppchi2-c17+: Internal constants
Constant, +ppchi2-c18+: Internal constants
Constant, +ppchi2-c19+: Internal constants
Constant, +ppchi2-c2+: Internal constants
Constant, +ppchi2-c20+: Internal constants
Constant, +ppchi2-c21+: Internal constants
Constant, +ppchi2-c22+: Internal constants
Constant, +ppchi2-c23+: Internal constants
Constant, +ppchi2-c24+: Internal constants
Constant, +ppchi2-c25+: Internal constants
Constant, +ppchi2-c26+: Internal constants
Constant, +ppchi2-c27+: Internal constants
Constant, +ppchi2-c28+: Internal constants
Constant, +ppchi2-c29+: Internal constants
Constant, +ppchi2-c3+: Internal constants
Constant, +ppchi2-c30+: Internal constants
Constant, +ppchi2-c31+: Internal constants
Constant, +ppchi2-c32+: Internal constants
Constant, +ppchi2-c33+: Internal constants
Constant, +ppchi2-c34+: Internal constants
Constant, +ppchi2-c35+: Internal constants
Constant, +ppchi2-c36+: Internal constants
Constant, +ppchi2-c37+: Internal constants
Constant, +ppchi2-c38+: Internal constants
Constant, +ppchi2-c4+: Internal constants
Constant, +ppchi2-c5+: Internal constants
Constant, +ppchi2-c6+: Internal constants
Constant, +ppchi2-c7+: Internal constants
Constant, +ppchi2-c8+: Internal constants
Constant, +ppchi2-c9+: Internal constants
Constant, +ppchi2-e+: Internal constants
Constant, +ppchi2-pmax+: Internal constants
Constant, +ppchi2-pmin+: Internal constants
Constant, +ppnd-a0+: Internal constants
Constant, +ppnd-a1+: Internal constants
Constant, +ppnd-a2+: Internal constants
Constant, +ppnd-a3+: Internal constants
Constant, +ppnd-b1+: Internal constants
Constant, +ppnd-b2+: Internal constants
Constant, +ppnd-b3+: Internal constants
Constant, +ppnd-b4+: Internal constants
Constant, +ppnd-c0+: Internal constants
Constant, +ppnd-c1+: Internal constants
Constant, +ppnd-c2+: Internal constants
Constant, +ppnd-c3+: Internal constants
Constant, +ppnd-d1+: Internal constants
Constant, +ppnd-d2+: Internal constants
Constant, +sapa-10-over-log-10+: Internal constants
Constant, +sapa-2-pi+: Internal constants
Constant, +sapa-4-time-exp-of-1-over-4+: Internal constants
Constant, +sapa-4-time-exp-of-minus-1-point-35+: Internal constants
Constant, +sapa-minus-2-pi+: Internal constants
Constant, +sapa-sqrt-8-over-e+: Internal constants
Constant, +sqrt-of-two-pi+: Internal constants

S
Special Variable, *abscissas-32-point*: Internal special variables
Special Variable, *sapa-cached-pre-fft-arrays*: Internal special variables
Special Variable, *weights-32-point*: Internal special variables
Special Variable, +coefficents-for-log-of-gamma+: Internal special variables
Special Variable, +nr-gser-eps+: Internal special variables
Special Variable, +nr-gser-itmax+: Internal special variables
Special Variable, +use-pre-fft-with-cache-p+: Internal special variables

Jump to:   *   +  
C   S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   P   S  
Index Entry  Section

P
Package, sapa: The sapa package
Package, sapaclisp-asd: The sapaclisp-asd package

S
sapa: The sapa package
sapaclisp: The sapaclisp system
sapaclisp-asd: The sapaclisp-asd package
System, sapaclisp: The sapaclisp system

Jump to:   P   S