在包wavelets
中,您可以使用函数dwt
(离散波变换)和filter
设置为的参数进行 Haar 小波变换"haar"
:
library(wavelets)
k <- c(4,6,10,12,8,6,5,5)
w <- dwt(k, filter="haar")
dwt
对象是相当复杂的 S4 对象,所以我无法解释它的每个部分的含义(我自己对小波一无所知),我建议您阅读?dwt
,但您要查找的内容似乎包含在 slot V
:
w@V[[1]]
[,1]
[1,] 7.071068
[2,] 15.556349
[3,] 9.899495
[4,] 7.071068
以下是对象包含的所有信息,以供参考:
An object of class "dwt"
Slot "W":
$W1
[,1]
[1,] 1.414214
[2,] 1.414214
[3,] -1.414214
[4,] 0.000000
$W2
[,1]
[1,] 6
[2,] -2
$W3
[,1]
[1,] -2.828427
Slot "V":
$V1
[,1]
[1,] 7.071068
[2,] 15.556349
[3,] 9.899495
[4,] 7.071068
$V2
[,1]
[1,] 16
[2,] 12
$V3
[,1]
[1,] 19.79899
Slot "filter":
Filter Class: Daubechies
Name: HAAR
Length: 2
Level: 1
Wavelet Coefficients: 7.0711e-01 -7.0711e-01
Scaling Coefficients: 7.0711e-01 7.0711e-01
Slot "level":
[1] 3
Slot "n.boundary":
[1] 0 0 0
Slot "boundary":
[1] "periodic"
Slot "series":
[,1]
[1,] 4
[2,] 6
[3,] 10
[4,] 12
[5,] 8
[6,] 6
[7,] 5
[8,] 5
Slot "class.X":
[1] "numeric"
Slot "attr.X":
list()
Slot "aligned":
[1] FALSE
Slot "coe":
[1] FALSE