hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_wav_1d_cont (c09ba)

Purpose

nag_wav_1d_cont (c09ba) computes the real, continuous wavelet transform in one dimension.

Syntax

[c, ifail] = c09ba(wavnam, wparam, x, scales, 'n', n, 'nscal', nscal)
[c, ifail] = nag_wav_1d_cont(wavnam, wparam, x, scales, 'n', n, 'nscal', nscal)

Description

nag_wav_1d_cont (c09ba) computes the real part of the one-dimensional, continuous wavelet transform
Cs,k = x(t) 1/(sqrt(s)) ψ* ((tk)/s) dt ,
Cs,k = x(t) 1 s ψ* ( t-k s ) dt ,
of a signal x(t)x(t) at scale ss and position kk, where the signal is sampled discretely at nn equidistant points xixi, for i = 1,2,,ni=1,2,,n. ψψ is the wavelet function, which can be chosen to be the Morlet wavelet, the derivatives of a Gaussian or the Mexican hat wavelet (** denotes the complex conjugate). The integrals of the scaled, shifted wavelet function are approximated and the convolution is then computed.
The mother wavelets supplied for use with this function are defined as follows.
  1. The Morlet wavelet (real part) with nondimensional wave number κκ is
    ψ(x) = 1/( π1 / 4 ) (cos(κx)eκ2 / 2) ex2 / 2 ,
    ψ(x) = 1 π 1/4 ( cos(κx) - e -κ2/2 ) e -x2/2 ,
    where the correction term, eκ2 / 2e-κ2/2 (required to satisfy the admissibility condition) is included.
  2. The derivatives of a Gaussian are obtained from
    ψ̂(m) (x) = ( dm (e x2 ) )/( d xm ) ,
    ψ^(m) (x) = dm ( e -x2 ) d xm ,
    taking m = 1,,8m=1,,8. These are the Hermite polynomials multiplied by the Gaussian. The sign is then adjusted to give ψ̂(m)(0) > 0ψ^(m)(0)>0 when mm is even while the sign of the succeeding odd derivative, ψ̂(m + 1)ψ^(m+1), is made consistent with the preceding even numbered derivative. They are normalized by the L2L2-norm,
    pm =
    (∞ )∫[ψ̂(m)(x)]2dx − ∞ 1 / 2
    pm = ( - [ ψ^ (m) (x) ] 2 d x ) 1/2
    The resulting normalized derivatives can be written in terms of the Hermite polynomials, Hm(x)Hm(x), as
    ψ(m) (x) = ( α Hm(x) ex2 )/(pm) ,
    ψ (m) (x) = α Hm(x) e -x2 pm ,
    where
    α =
    { 1, when ​m = 0,3  mod  4; − 1, when ​m = 1,2  mod  4.
    α = { 1, when ​m=0,3 mod 4; -1, when ​m=1,2 mod 4.
    Thus, the derivatives of a Gaussian provided here are,
    ψ(1) (x) = (2/π)1 / 4 2 x ex2 ,
    ψ(1) (x) = - (2π) 1/4 2 x e -x2 ,
    ψ(2) (x) = (2/π)1 / 4 1/(sqrt(3)) (4x22) ex2 ,
    ψ(2) (x) = - (2π) 1/4 1 3 ( 4x2 - 2 ) e -x2 ,
    ψ(3) (x) = (2/π)1 / 4 1/(sqrt(15)) (8x312x) ex2 ,
    ψ(3) (x) = (2π) 1/4 115 ( 8x3 - 12x ) e -x2 ,
    ψ(4) (x) = (2/π)1 / 4 1/(sqrt(105)) (16x448x2 + 12) ex2 ,
    ψ(4) (x) = ( 2π ) 1/4 1105 ( 16x4 - 48x2 + 12 ) e -x2 ,
    ψ(5) (x) = (2/π)1 / 4 1/(3sqrt(105)) (32x5160x3 + 120x) ex2 ,
    ψ(5) (x) = - ( 2π ) 1/4 1 3105 ( 32x5 - 160x3 + 120x ) e -x2 ,
    ψ(6) (x) = (2/π)1 / 4 1/(3sqrt(1155)) (64x6480x4 + 720x2120) ex2 ,
    ψ(6) (x) = - (2π) 1/4 1 31155 ( 64x6 - 480x4 + 720x2 - 120 ) e -x2 ,
    ψ(7) (x) = (2/π)1 / 4 1/(3sqrt(15015)) (128x71344x5 + 3360x31680x) ex2 ,
    ψ(7) (x) = (2π) 1/4 1 315015 ( 128x7 - 1344x5 + 3360x3 - 1680x ) e -x2 ,
    ψ(8) (x) = (2/π)1 / 4 1/(45sqrt(1001)) (256x83584x6 + 13440x413440x2 + 1680) ex2 .
    ψ(8) (x) = (2π) 1/4 1 451001 ( 256x8 - 3584x6 + 13440x4 - 13440x2 + 1680 ) e -x2 .
  3. The second derivative of a Gaussian is known as the Mexican hat wavelet and is supplied as an additional function in the form
    ψ(x) = 2/((sqrt(3)π1 / 4)) (1x2) ex2 / 2 .
    ψ(x) = 2 ( 3 π1/4 ) (1-x2) e -x2/2 .
    The remaining normalized derivatives of a Gaussian can be expressed as multiples of the exponential e t2 / 2 e - t2 / 2  by applying the substitution x = t / sqrt(2) x = t / 2  followed by multiplication with the scaling factor, 1 / root(4,2) 1 / 24 .

References

Daubechies I (1992) Ten Lectures on Wavelets SIAM, Philadelphia

Parameters

Compulsory Input Parameters

1:     wavnam – string
The name of the mother wavelet. See the C09 Chapter Introduction for details.
wavnam = 'MORLET'wavnam='MORLET'
Morlet wavelet.
wavnam = 'DGAUSS'wavnam='DGAUSS'
Derivative of a Gaussian wavelet.
wavnam = 'MEXHAT'wavnam='MEXHAT'
Mexican hat wavelet.
Constraint: wavnam = 'MORLET'wavnam='MORLET', 'DGAUSS''DGAUSS' or 'MEXHAT''MEXHAT'.
2:     wparam – int64int32nag_int scalar
The nondimensional wave number for the Morlet wavelet or the order of the derivative for the Gaussian wavelet. It is not referenced when wavnam = 'MEXHAT'wavnam='MEXHAT'.
Constraints:
  • if wavnam = 'MORLET'wavnam='MORLET', 5wparam205wparam20;
  • if wavnam = 'DGAUSS'wavnam='DGAUSS', 1wparam81wparam8.
3:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n2n2.
x contains the input dataset x(j) = xjxj=xj, for j = 1,2,,nj=1,2,,n.
4:     scales(nscal) – int64int32nag_int array
nscal, the dimension of the array, must satisfy the constraint nscal1nscal1.
The scales at which the transform is to be computed.
Constraint: scales(i)1scalesi1, for i = 1,2,,nscali=1,2,,nscal.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array x.
The size, nn, of the input dataset xx.
Constraint: n2n2.
2:     nscal – int64int32nag_int scalar
Default: The dimension of the array scales.
The dimension of the array scales and the first dimension of the array c as declared in the (sub)program from which nag_wav_1d_cont (c09ba) is called. The number of scales to be computed.
Constraint: nscal1nscal1.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     c(nscal,n) – double array
The transform coefficients at the requested scales, where c(i,j)cij is the transform coefficient Ci,jCi,j at scale ii and position jj.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry, wavnam had an illegal value.
  ifail = 2ifail=2
Constraint: if wavnam = 'DGAUSS'wavnam='DGAUSS', 1wparam81wparam8.
Constraint: if wavnam = 'MORLET'wavnam='MORLET', 5wparam205wparam20.
  ifail = 3ifail=3
Constraint: n2n2.
  ifail = 5ifail=5
Constraint: nscal1nscal1.
  ifail = 999ifail=-999
Dynamic memory allocation failed.

Accuracy

The accuracy of nag_wav_1d_cont (c09ba) is determined by the fact that the convolution must be computed as a discrete approximation to the continuous form. The input signal, xx, is taken to be piecewise constant using the supplied discrete values.

Further Comments

Workspace is internally allocated by nag_wav_1d_cont (c09ba). The total size of these arrays is 213 + (n + nk1) 213 + ( n + nk - 1 )  double elements and nknk integer elements, where nk = k × max (scales(i)) nk = k × max(scalesi)  and k = 17k=17 when wavnam = 'MORLET'wavnam='MORLET' or 'DGAUSS''DGAUSS' and k = 11k=11 when wavnam = 'MEXHAT'wavnam='MEXHAT'.

Example

function nag_wav_1d_cont_example
wavnam = 'Morlet';
wparam = int64(5);
scales = [int64(1), 2, 3, 4];
x = zeros(10,1);
x(5) = 1;


[c, ifail] = nag_wav_1d_cont(wavnam, wparam, x, scales);
fprintf('\nNumber of Scales : 4\n');
fprintf('Wavelet coefficients c :\n');
fprintf('Scale:    %d           %d            %d            %d\n', scales);
for j = 1:10
  fprintf('    %11.4e  %11.4e  %11.4e  %11.4e\n', c(:,j));
end
 

Number of Scales : 4
Wavelet coefficients c :
Scale:    1           2            3            4
    -1.7651e-05   1.5012e-04   5.2331e-02   1.4454e-01
    -1.3643e-03  -5.8141e-02   1.7057e-01  -8.4364e-02
     4.6511e-03   1.8442e-01  -1.4891e-01  -2.8870e-01
     8.9294e-02  -2.6380e-01  -2.6822e-01  -9.4993e-02
    -9.2563e-02   1.3289e-01   2.5680e-01   2.8293e-01
    -9.2563e-02   1.3289e-01   2.5680e-01   2.8293e-01
     8.9294e-02  -2.6380e-01  -2.6822e-01  -9.4993e-02
     4.6511e-03   1.8442e-01  -1.4891e-01  -2.8870e-01
    -1.3643e-03  -5.8141e-02   1.7057e-01  -8.4364e-02
    -1.7651e-05   1.5012e-04   5.2331e-02   1.4454e-01

function c09ba_example
wavnam = 'Morlet';
wparam = int64(5);
scales = [int64(1), 2, 3, 4];
x = zeros(10,1);
x(5) = 1;


[c, ifail] = c09ba(wavnam, wparam, x, scales);
fprintf('\nNumber of Scales : 4\n');
fprintf('Wavelet coefficients c :\n');
fprintf('Scale:    %d           %d            %d            %d\n', scales);
for j = 1:10
  fprintf('    %11.4e  %11.4e  %11.4e  %11.4e\n', c(:,j));
end
 

Number of Scales : 4
Wavelet coefficients c :
Scale:    1           2            3            4
    -1.7651e-05   1.5012e-04   5.2331e-02   1.4454e-01
    -1.3643e-03  -5.8141e-02   1.7057e-01  -8.4364e-02
     4.6511e-03   1.8442e-01  -1.4891e-01  -2.8870e-01
     8.9294e-02  -2.6380e-01  -2.6822e-01  -9.4993e-02
    -9.2563e-02   1.3289e-01   2.5680e-01   2.8293e-01
    -9.2563e-02   1.3289e-01   2.5680e-01   2.8293e-01
     8.9294e-02  -2.6380e-01  -2.6822e-01  -9.4993e-02
     4.6511e-03   1.8442e-01  -1.4891e-01  -2.8870e-01
    -1.3643e-03  -5.8141e-02   1.7057e-01  -8.4364e-02
    -1.7651e-05   1.5012e-04   5.2331e-02   1.4454e-01


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013