2
$\begingroup$

I am fiddling with wavelet coefficients in Mathematica, and for simplicty only
a real valued Wavlet.
Lets say we have the data:

data = Table[Sin[x], {x, 0, 2 Pi, Pi/5}] // N

and compute the CWT:

cwt = ContinuousWaveletTransform[data, MexicanHatWavelet[1]]

so the coefficients are:

cwt[All, "Values"]
{{-0.0812726, 0.0335765, 0.0359608, 0.0407693, 0.0236837, 
  3.02788*10^-17, -0.0236837, -0.0407693, -0.0359608, -0.0335765, 
  0.0812726}, {-0.112088, 0.0450134, 0.0572861, 0.0614269, 0.0366589, 
  4.2895*10^-17, -0.0366589, -0.0614269, -0.0572861, -0.0450134, 
  0.112088}, {-0.147891, 0.0573294, 0.090965, 0.0922296, 0.0565661, 
  5.55112*10^-17, -0.0565661, -0.0922296, -0.090965, -0.0573294, 
  0.147891}, {-0.183613, 0.0686418, 0.142807, 0.138245, 0.0867338, 
  6.56041*10^-17, -0.0867338, -0.138245, -0.142807, -0.0686418, 
  0.183613}, {-0.20979, 0.0775932, 0.219216, 0.207302, 0.131629, 
  6.05576*10^-17, -0.131629, -0.207302, -0.219216, -0.0775932, 
  0.20979}, {-0.21385, 0.0873197, 0.325176, 0.310892, 0.197009, 
  6.05576*10^-17, -0.197009, -0.310892, -0.325176, -0.0873197, 
  0.21385}, {-0.184736, 0.111707, 0.462557, 0.463126, 0.290268, 
  4.03717*10^-17, -0.290268, -0.463126, -0.462557, -0.111707, 
  0.184736}, {-0.118036, 0.178857, 0.633038, 0.675019, 0.420508, 
  4.03717*10^-17, -0.420508, -0.675019, -0.633038, -0.178857, 
  0.118036}}

When calculating them like mentioned in the documentation:

func[u_] := WaveletPsi[MexicanHatWavelet[1], u]

and

wt[u_, s_, data__] := (1/Sqrt[s])* 
  Sum[data[[k]]*func[(k - u)/s], {k, 1, data // Length}]

with

scales = cwt["Scales"][[All, 2]]

the following is computed:

mycwt = 
 Table[1/Sqrt[scales[[i]]] w[u, scales[[i]], data], {i, 
   Length@scales}, {u, Length@data}]
{{-0.0651336, 1.59815, 2.58587, 2.58587, 1.59815, 
  2.6551*10^-18, -1.59815, -2.58587, -2.58587, -1.59815, 
  0.0651336}, {-0.19062, 1.12408, 1.81881, 1.81881, 1.12408, 
  1.81323*10^-17, -1.12408, -1.81881, -1.81881, -1.12408, 
  0.19062}, {-0.339154, 0.656187, 1.06232, 1.06232, 
  0.65655, -3.20472*10^-17, -0.65655, -1.06232, -1.06232, -0.656187, 
  0.339154}, {-0.423811, 0.332771, 0.547462, 0.547463, 
  0.338351, -2.51996*10^-17, -0.338351, -0.547463, -0.547462, \
-0.332771, 0.423811}, {-0.430708, 0.187554, 0.356279, 0.356351, 
  0.220237, 
  1.23804*10^-17, -0.220237, -0.356351, -0.356279, -0.187554, 
  0.430708}, {-0.416897, 0.139704, 0.382953, 0.384621, 0.237711, 
  1.8845*10^-17, -0.237711, -0.384621, -0.382953, -0.139704, 
  0.416897}, {-0.413798, 0.12342, 0.494874, 0.508019, 
  0.314085, -1.02473*10^-18, -0.314085, -0.508019, -0.494874, \
-0.12342, 0.413798}, {-0.410421, 0.130445, 0.625518, 0.674272, 
  0.418447, -2.67123*10^-17, -0.418447, -0.674272, -0.625518, \
-0.130445, 0.410421}}

Could anyone enlight me please where the differences come from?

$\endgroup$
  • $\begingroup$ thanks m_goldberg for helping a novice on SE $\endgroup$ – wvt_beginner Jan 9 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.