({{, (RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform])[{(Subscript[x, 1]),(Subscript[x, 2]),…}] 
gives the continuous wavelet transform of a list of values (Subscript[x, i]).}, {, (RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform])[data,wave]
gives the continuous wavelet transform using the wavelet wave.}, {, (RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform])[data,wave,{noct,nvoc}]
gives the continuous wavelet transform using noct octaves with nvoc voices per octave.}, {, (RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform])[sound,…]
gives the continuous wavelet transform of sampled sound.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform]) gives a (RefLink[ContinuousWaveletData, paclet:ref/ContinuousWaveletData]) object.

Properties of the (RefLink[ContinuousWaveletData, paclet:ref/ContinuousWaveletData]) cwd can be found using cwd["prop"]. A list of available properties can found using cwd["Properties"].

The resulting wavelet coefficients are arrays of the same dimensions as the input data.

The possible wavelets wave include:

The default wave is (RefLink[MexicanHatWavelet, paclet:ref/MexicanHatWavelet])[].

The default value for noct is given by (Floor[(Subscript[log, 2])((n/2))]), where n is the length of the input.  »

The default value for nvoc is 4.

The continuous wavelet transform of a function x(t) is given by w(u,s)=(1/(Sqrt[s]))(∫_(-∞)^∞)x(t) (Conjugate[ψ])(((t-u)/s))dt.

The continuous wavelet transform of a uniformly sampled sequence {(Subscript[x, 1]),(Subscript[x, 2]),…}={x((Subscript[t, 0])),x(Δ+(Subscript[t, 0])),…} is given by w(u,s)=(1/(Sqrt[s]))(∑_(k=1)^n)(Subscript[x, k]) (Conjugate[ψ])(((Δ (k-u))/s)).

The scaling parameter s is given by equal-tempered scale (Subscript[s, oct,voc])=α (2^(oct-1)) (2^(voc/nvoc)) where oct is the octave number, voc the voice number, and α the smallest wavelet scale.

For each scale (Subscript[s, oct,voc]), the (RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform]) computes the wavelet coefficients {w(1,(Subscript[s, oct,voc])),w(2,(Subscript[s, oct,voc])),…,w(n,(Subscript[s, oct,voc]))}.

The following options can be given:

(RefLink[Padding, paclet:ref/Padding]) pads the input data to the next higher power of 2 to reduce boundary effects. The settings for (RefLink[Padding, paclet:ref/Padding]) are the same as for the padding argument used in (RefLink[ArrayPad, paclet:ref/ArrayPad]).

(RefLink[InverseContinuousWaveletTransform, paclet:ref/InverseContinuousWaveletTransform]) gives the inverse transform.

OpenersPrimaryExamplesSection(Spacer1)Examples  (36)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Compute a continuous wavelet transform using (RefLink[MexicanHatWavelet, paclet:ref/MexicanHatWavelet]):

cwd=ContinuousWaveletTransform[{56,40,8,24,48,48,40,16}]

Plot the coefficients:

ListLinePlot[cwd[All,"Values"]]

Perform an inverse continuous wavelet transform:

InverseContinuousWaveletTransform[cwd]

Transform a sampled (RefLink[Sound, paclet:ref/Sound]) object:

Play[(∑_n^5)Sin[2000 (2^t) n t],{t,2,3}]

cwd=ContinuousWaveletTransform[%]

Plot a scalogram:

WaveletScalogram[cwd]

OpenersExampleSection1(Spacer1)Scope  (18)

OpenersExampleSubsection0(Spacer1)Basic Uses  (6)

Compute a continuous wavelet transform:

data=Table[HeavisideLambda[x],{x,-2,2,(4/1023)}];

cwt=ContinuousWaveletTransform[data]

Show all the voices for the 8(^th) octave:

ListLinePlot[Abs[cwt[{8,_}][[All,2]]],PlotRange->All]

Use (RefLink[Normal, paclet:ref/Normal]) to get all wavelet coefficients explicitly:

cwt=ContinuousWaveletTransform[{0,0,1,0,0},MexicanHatWavelet[1]]

Normal[cwt]

Also use (RefLink[All, paclet:ref/All]) as an argument to get all coefficients:

cwt[All]

Use "IndexMap" to find out what wavelet coefficients are available:

cwt=ContinuousWaveletTransform[{0,0,1,0,0},MexicanHatWavelet[1]];

cwt["IndexMap"]

Extract specific coefficient arrays:

cwt[{1,1}]

cwt[{1,4}]

Extract several wavelet coefficients corresponding to the list of wavelet index specifications:

cwt[{{1,1},{1,3}}]

Extract all coefficients whose wavelet indexes match a pattern:

cwt[{1,_}]

cwt[{{_,1},{_,4}}]

cwt[{_,1|4}]

(RefLink[WaveletScalogram, paclet:ref/WaveletScalogram]) gives a time scale representation of wavelet coefficients:

data=Table[Sign[Cos[(x^2)]],{x,-6,6,(12./1023)}];

ListLinePlot[data]

cwt=ContinuousWaveletTransform[data];

WaveletScalogram[cwt,AxesLabel->{"time","scale"}]

More voices per octave increases the scale resolution:

data=Table[Sin[(x^2)],{x,0,10,0.02}];

{cwt1,cwt2}=Table[ContinuousWaveletTransform[data,DGaussianWavelet[5],{Automatic,voc}],{voc,{4,16}}];

{WaveletScalogram[cwt1,PlotLabel->"4 voices/octave"],WaveletScalogram[cwt2,PlotLabel->"16 voices/octave"]}

Higher number of octaves gives a wider spectrum of scale range:

data=Function[x,x Sin[Exp[x] x]][Range[2,5,0.001]];

{cwt1,cwt2}=Table[ContinuousWaveletTransform[data,Automatic,{oct,Automatic}],{oct,{5,8}}];

{WaveletScalogram[cwt1,PlotLabel->"5 octaves"],WaveletScalogram[cwt2,PlotLabel->"8 octaves"]}

OpenersExampleSubsection1(Spacer1)Time and Scale Features  (4)

A single frequency shows up as a horizontal band at the equivalent scale:

data1=Table[Cos[20 π x],{x,0,1,(1/1023)}];

ListLinePlot[data1]

cwt1=ContinuousWaveletTransform[data1,GaborWavelet[6]];

WaveletScalogram[cwt1,ColorFunction->"SolarColors"]

Multiple frequencies show up as multiple bands at the equivalent scales:

data2=Table[Cos[20 π x]+Cos[(Sqrt[2]) 50 π x],{x,0,1,(1/1023)}];

ListLinePlot[data2]

cwt2=ContinuousWaveletTransform[data2,GaborWavelet[6]];

WaveletScalogram[cwt2,ColorFunction->"SolarColors"]

Sinusoid with linearly increasing frequency:

data3=Block[{fr=0},Table[Sin[(fr+=0.5)x],{x,0,1,(1/1023)}]];

ListLinePlot[data3]

cwt2=ContinuousWaveletTransform[data3,GaborWavelet[6]];

WaveletScalogram[cwt2,ColorFunction->"SolarColors"]

Wavelet transform gives a good time localization of features:

data=Table[Sin[4 π t]+2 Exp[-(10^5) ((((1/3)-t))^2)],{t,0,1,(1/511)}];

ListLinePlot[data]

cwt=ContinuousWaveletTransform[data,PaulWavelet[5],{7,12},SampleRate->511];

WaveletScalogram[cwt,ColorFunction->"AvocadoColors"]

Higher frequencies are resolved at lower octaves and lower frequencies at higher octaves:

data=Table[Piecewise[{{Sin[2 π 10 t],0≤t<(1/4)},{Sin[2 π 25 t],(1/4)≤t<(1/2)},{Sin[2 π 50 t],(1/2)≤t<(3/4)},{Sin[2 π 100 t],(3/4)≤t≤1}}],{t,0,1,(1/1023)}];

ListLinePlot[data,AspectRatio->0.2]

cwd=ContinuousWaveletTransform[data,DGaussianWavelet[5],{Automatic,12}];

WaveletScalogram[cwd,ColorFunction->"RustTones"]

Resolve time and frequency features of a signal:

data=Table[Cos[40 π x] Exp[-100 π (((x-0.7))^2)]+Cos[140 π x] Exp[-50 π (((x-0.2))^2)],{x,0,1,(1/1023)}];

ListLinePlot[data,PlotRange->All]

Use (RefLink[GaborWavelet, paclet:ref/GaborWavelet]) to perform a continuous wavelet transform:

cwd=ContinuousWaveletTransform[data,GaborWavelet[8],SampleRate->1023];

There is an inverse relationship between scale values and frequency values:

freq=(#1[[1]]->(1023/(#1[[2]]))&)/@cwd["Scales"]

Find pairs of {oct,voc} that resolve frequencies 20 Hz and 70 Hz:

Cases[freq,u_/;19≤Last[u]≤21]

Cases[freq,u_/;69≤Last[u]≤71]

Verify using a (RefLink[WaveletScalogram, paclet:ref/WaveletScalogram]):

WaveletScalogram[cwd,ColorFunction->"BrassTones"]

OpenersExampleSubsection2(Spacer1)Wavelet Families  (6)

Compute the wavelet transform using different wavelet families:

data=Table[Sin[(x^2)]+Cos[(x^3)],{x,0,3 π,0.01}];

ListLinePlot[data]

A narrow wavelet function will have good time and scale resolution:

cwt1=ContinuousWaveletTransform[data,MexicanHatWavelet[1]];

WaveletScalogram[cwt1]

A broad wavelet function will have poor time and scale resolution:

cwt2=ContinuousWaveletTransform[data,GaborWavelet[3]]

WaveletScalogram[cwt2]

Use different families of wavelets to capture different features:

data=Table[Sign[Cos[(x^2)]],{x,-6,6,(12./1023)}];

ListLinePlot[data]

(RefLink[MexicanHatWavelet, paclet:ref/MexicanHatWavelet]) (default):

cwt=ContinuousWaveletTransform[data,MexicanHatWavelet[]];

ListPlot3D[Re@cwt[All,"Values"],ColorFunction->"DarkRainbow",AxesLabel->{"time","scale"},Mesh->None,PlotRange->All]

(RefLink[DGaussianWavelet, paclet:ref/DGaussianWavelet]):

data=Table[Sign[Cos[(x^2)]],{x,-6,6,(12./1023)}];

cwt=ContinuousWaveletTransform[data,DGaussianWavelet[]];

ListPlot3D[Re@cwt[All,"Values"],ColorFunction->"DarkRainbow",AxesLabel->{"time","scale"},Mesh->None,PlotRange->All]

(RefLink[GaborWavelet, paclet:ref/GaborWavelet]):

data=Table[Sign[Cos[(x^2)]],{x,-6,6,(12./1023)}];

cwt=ContinuousWaveletTransform[data,GaborWavelet[3]];

ListPlot3D[Abs@cwt[All,"Values"],ColorFunction->"DarkRainbow",AxesLabel->{"time","scale"},Mesh->None,PlotRange->All]

(RefLink[MorletWavelet, paclet:ref/MorletWavelet]):

data=Table[Sign[Cos[(x^2)]],{x,-6,6,(12./1023)}];

cwt=ContinuousWaveletTransform[data,MorletWavelet[]];

ListPlot3D[Abs@cwt[All,"Values"],ColorFunction->"DarkRainbow",AxesLabel->{"time","scale"},Mesh->None,PlotRange->All]

(RefLink[PaulWavelet, paclet:ref/PaulWavelet]):

data=Table[Sign[Cos[(x^2)]],{x,-6,6,(12./1023)}];

cwt=ContinuousWaveletTransform[data,PaulWavelet[]];

ListPlot3D[Abs@cwt[All,"Values"],ColorFunction->"DarkRainbow",AxesLabel->{"time","scale"},Mesh->None,PlotRange->All]

OpenersExampleSubsection3(Spacer1)Sound  (2)

(RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform]) works on (RefLink[Sound, paclet:ref/Sound]) as input:

sdata=Play[Sin[5000 t]+Sin[1000 t]+Cos[500 t]+Cos[200 t],{t,0,1}]

cwt=ContinuousWaveletTransform[sdata,DGaussianWavelet[5]];

WaveletScalogram[cwt,ColorFunction->"StarryNightColors"]

Speech analysis using (RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform]):

snd=ExampleData[{"Sound","Apollo11ReturnSafely"}]

cwd=ContinuousWaveletTransform[snd,GaborWavelet[6],{Automatic,12}];

The orange patches correspond to the words "You will return safely to Earth":

WaveletScalogram[cwd,{4|5|6|7,_}]

Extract octaves 5 and 6:

cwd2=WaveletMapIndexed[#1 0.0&,cwd,Except[{5|6,_}]]

Sound[InverseContinuousWaveletTransform[cwd2],SoundVolume->2]

OpenersExampleSection2(Spacer1)Options  (9)

OpenersExampleSubsection4(Spacer1)Padding  (3)

The settings for (RefLink[Padding, paclet:ref/Padding]) are the same as the methods for (RefLink[ArrayPad, paclet:ref/ArrayPad]), including "Periodic":

ArrayPad[{a,b,c},4,"Periodic"]

"Reversed":

ArrayPad[{a,b,c},4,"Reversed"]

"ReversedNegation":

ArrayPad[{a,b,c},4,"ReversedNegation"]

"Reflected":

ArrayPad[{a,b,c},4,"Reflected"]

"ReflectedDifferences":

ArrayPad[{a,b,c},3,"ReflectedDifferences"]

"ReversedDifferences":

ArrayPad[{a,b,c},4,"ReversedDifferences"]

"Extrapolated":

ArrayPad[{a,b,c},3,"Extrapolated"]

(RefLink[Padding, paclet:ref/Padding]) has no effect on the length of wavelet coefficients:

cwd=ContinuousWaveletTransform[Range[16]];

(Length[#1]&)/@cwd[All][[All,2]]

(RefLink[Padding, paclet:ref/Padding]) pads the input data to the next higher power of 2 to reduce boundary effects:

data=Table[Sin[20 x],{x,0,1,(1/1023)}];

cwt1=ContinuousWaveletTransform[data,MexicanHatWavelet[4],Padding->None,WaveletScale->Automatic];
rdata1=InverseContinuousWaveletTransform[cwt1];

cwt2=ContinuousWaveletTransform[data,MexicanHatWavelet[4],Padding->"Reflected",WaveletScale->Automatic];
rdata2=InverseContinuousWaveletTransform[cwt2];

cwt3=ContinuousWaveletTransform[data,MexicanHatWavelet[4],Padding->"Extrapolated",WaveletScale->Automatic];
rdata3=InverseContinuousWaveletTransform[cwt3];

Boundary effects at the start:

ListLinePlot[{data[[1;;50]],rdata1[[1;;50]],rdata2[[1;;50]],rdata3[[1;;50]]},PlotStyle->{Red,Green,Blue,Orange},BaseStyle->Thick]

Boundary effects at the end:

ListLinePlot[{data[[-50;;-1]],rdata1[[-50;;-1]],rdata2[[-50;;-1]],rdata3[[-50;;-1]]},PlotStyle->{Red,Green,Blue,Orange},BaseStyle->Thick]

OpenersExampleSubsection5(Spacer1)WaveletScale  (1)

(RefLink[WaveletScale, paclet:ref/WaveletScale]) indicates the smallest resolvable scale used for the transform:

data=Table[Sin[(x^2)],{x,0,3 π,((3 π)/1023)}];

ListLinePlot[data]

cwt=ContinuousWaveletTransform[data,GaborWavelet[6],WaveletScale->1];

The scales used are given as ws (2^(oct-1)) (2^(i/voc)) with ws wavelet scale, oct octave, and voc voice:

{ws,oct,voc}=cwt[{"WaveletScale","Octaves","Voices"}];

Table[ws (2^(j/voc)),{j,1,oct voc}]==cwt["Scales"][[All,2]]

OpenersExampleSubsection6(Spacer1)SampleRate  (3)

For lists, the (RefLink[Automatic, paclet:ref/Automatic]) value of (RefLink[SampleRate, paclet:ref/SampleRate]) is set to 1:

cwt1=ContinuousWaveletTransform[Table[Sin[(x^2)],{x,0,1,0.001}]];

cwt1["SampleRate"]

Explicitly set the sample rate:

cwt2=ContinuousWaveletTransform[Table[Sin[(x^2)],{x,0,1,0.001}],SampleRate->1000];

cwt2["SampleRate"]

For (RefLink[Sound, paclet:ref/Sound]) data, the (RefLink[Automatic, paclet:ref/Automatic]) value of (RefLink[SampleRate, paclet:ref/SampleRate]) is extracted from the (RefLink[Sound, paclet:ref/Sound]) data object:

sdata=Sound[{Play[Sin[1000 t (1+(t^2))],{t,0,.2}],Play[Sin[500 t (1+(t^3))],{t,0,.5}]}]

cwt=ContinuousWaveletTransform[sdata];

cwt["SampleRate"]

(RefLink[SampleRate, paclet:ref/SampleRate]) is used for normalizing wavelet transform coefficients:

sdata=Sound[{Play[Sin[1000 t (1+(t^2))],{t,0,.2}],Play[Sin[500 t (1+(t^3))],{t,0,.5}]}]

cwt=ContinuousWaveletTransform[sdata,Automatic,{Automatic,16}]

WaveletScalogram[cwt,ColorFunction->"BlueGreenYellow"]

OpenersExampleSubsection7(Spacer1)WorkingPrecision  (2)

By default, (RefLink[WorkingPrecision, paclet:ref/WorkingPrecision])->(RefLink[MachinePrecision, paclet:ref/MachinePrecision]) is used:

data=RandomInteger[1,{10}];

cwt1=ContinuousWaveletTransform[data]

cwt2=ContinuousWaveletTransform[data,WorkingPrecision->MachinePrecision]

cwt1==cwt2

Use higher-precision computation:

data=RandomInteger[1,{8}];

cwt=ContinuousWaveletTransform[data,MexicanHatWavelet[],WorkingPrecision->35]

cwt[{1,1}]

{Precision[cwt],Accuracy[cwt]}

OpenersExampleSection3(Spacer1)Applications  (4)

OpenersExampleSubsection8(Spacer1)Identify Features  (2)

Real wavelet functions can be used to isolate peaks or discontinuities:

data=Table[HeavisideTheta[x],{x,-2,2,(4/1023)}];

ListLinePlot[data]

cwt=ContinuousWaveletTransform[data,DGaussianWavelet[4],{Automatic,12},Padding->"Fixed"]

WaveletScalogram[cwt]

Complex wavelets can be used to capture oscillatory behavior:

f[t_,ϵ_]:=(Sqrt[t (1-t)]) Sin[((2 π (1+ϵ))/(t+ϵ))]

data=Table[f[t,0.05],{t,0,1,(1/1023)}];

ListLinePlot[data]

cwt=ContinuousWaveletTransform[data,GaborWavelet[6],{Automatic,16}]

Amplitude of wavelet coefficients:

WaveletScalogram[cwt,ColorFunction->"BlueGreenYellow"]

Phase of wavelet coefficients:

WaveletScalogram[cwt,Automatic,Arg,ColorFunction->"BlueGreenYellow"]

OpenersExampleSubsection9(Spacer1)Filter Frequencies  (2)

(RefLink[ContinuousWaveletTransform, paclet:ref/ContinuousWaveletTransform]) can be used to filter frequencies:

f[x_]:=Sin[50 π x] Exp[-100 π (((x-0.5))^2)]+(Sin[50 π x]+2 Cos[140 π x]) Exp[-50 π (((x-0.2))^2)]+2 Sin[150 π x] Exp[-80 π (((x-0.8))^2)]

data=Table[f[x],{x,0.,1,(1/2047)}];

ListLinePlot[data,PlotRange->All]

cwt=ContinuousWaveletTransform[data,GaborWavelet[6],{10,16},Padding->0.0,SampleRate->2047,WaveletScale->Automatic];

WaveletScalogram[cwt,ColorFunction->"SolarColors"]

Filter the cosine with frequency 140π:

vec=ConstantArray[1,Length[data]];
vec[[1;;1000]]:=0.0

cwtThresh=WaveletMapIndexed[#1 vec&,cwt,{{4|5,_},{6,u_/;u<8}}];

WaveletScalogram[cwtThresh,ColorFunction->"SolarColors"]

Perform (RefLink[InverseContinuousWaveletTransform, paclet:ref/InverseContinuousWaveletTransform]) on a thresholded data object:

rdata=InverseContinuousWaveletTransform[cwtThresh];

ListLinePlot[{data[[1;;800]],rdata[[1;;800]]},PlotRange->All,PlotStyle->{Blue,{Red,Thick}}]

The final filtered signal:

ListLinePlot[rdata,PlotRange->All]

Identify musical notes using a scalogram:

Needs["Music`"]

Generate a sequence of pitches corresponding to an equal-tempered scale at 300 Hz:

m300=MusicScale[TemperedChromatic,300,1]

cwd = ContinuousWaveletTransform[m300,GaborWavelet[6],{7,8},SampleRate->8192];

Compute frequencies resolved corresponding to octaves and voices:

freq=(#1[[1]]->(8192/(#1[[2]]))&)/@cwd["Scales"];

Find pairs of {oct,voc} that resolve frequencies 300 Hz:

Cases[freq,u_/;280≤Last[u]≤320]

WaveletScalogram[cwd,{3|4|5|6|7,_}]

OpenersExampleSection4(Spacer1)Properties & Relations  (1)

The default value for octave oct is given by (Floor[(Subscript[log, 2])((n/2))]):

data=RandomReal[1,{100}];

oct=Floor[Log2[((Length[data])/2)]]

ContinuousWaveletTransform[data]==ContinuousWaveletTransform[data,Automatic,{oct,Automatic}]

Default value of voices voc is 4:

ContinuousWaveletTransform[data]==ContinuousWaveletTransform[data,Automatic,{Automatic,4}]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

Low-frequency data is resolved at higher octaves:

data=Cos[((Range[1000])/1000)];

Based on the length of input data, the (RefLink[Automatic, paclet:ref/Automatic]) setting for octaves resolved 8 octaves:

cwd1=ContinuousWaveletTransform[data,MorletWavelet[],Automatic]

ListLinePlot[{InverseContinuousWaveletTransform[cwd1],data}]

Increase the number of octaves to resolve the low-frequency component:

cwd2=ContinuousWaveletTransform[data,MorletWavelet[],{12,Automatic}]

ListLinePlot[{InverseContinuousWaveletTransform[cwd2],data}]

OpenersExampleSection6(Spacer1)Neat Examples  (1)

Scalogram of a (RefLink[Zeta, paclet:ref/Zeta]) function:

d=Re[Zeta[(1/2)+I Range[0,100,0.01]]];

ListLinePlot[d]

cwd=ContinuousWaveletTransform[d,GaborWavelet[6],{4,12},WaveletScale->100];

{WaveletScalogram[cwd,All,Re,ColorFunction->"CherryTones"],WaveletScalogram[cwd,All,Abs,ColorFunction->"CherryTones"]}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[InverseWaveletTransform, paclet:ref/InverseWaveletTransform])  ▪  (RefLink[ContinuousWaveletData, paclet:ref/ContinuousWaveletData])  ▪  (RefLink[DiscreteWaveletTransform, paclet:ref/DiscreteWaveletTransform])  ▪  (RefLink[WaveletScalogram, paclet:ref/WaveletScalogram])  ▪  (RefLink[WaveletMapIndexed, paclet:ref/WaveletMapIndexed])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Wavelet Analysis, paclet:guide/Wavelets])}, {▪(RefLinkPlain[Fourier Analysis, paclet:guide/FourierAnalysis])}, {▪(RefLinkPlain[Integral Transforms, paclet:guide/IntegralTransforms])}})}})