represents a Haar wavelet.
HaarWavelet
represents a Haar wavelet.
Details
- HaarWavelet defines a family of orthonormal wavelets.
- The scaling function (
) and wavelet function (
) have compact support lengths of 1. They have 1 vanishing moment and are symmetric. - The scaling function (
) is given by
. » - The wavelet function (
) is given by
. » - HaarWavelet can be used with such functions as DiscreteWaveletTransform, WaveletPhi, etc.
Examples
open all close allBasic Examples (3)
Plot[WaveletPhi[HaarWavelet[], x], {x, -1, 2}, Exclusions -> None]WaveletPhi[HaarWavelet[], x]Plot[WaveletPsi[HaarWavelet[], x], {x, -1, 2}, Exclusions -> None]WaveletPsi[HaarWavelet[], x]WaveletFilterCoefficients[HaarWavelet[], {"PrimalLowpass", "PrimalHighpass"}, WorkingPrecision -> ∞]Scope (10)
Basic Uses (4)
Compute primal lowpass filter coefficients:
WaveletFilterCoefficients[HaarWavelet[], "PrimalLowpass"]Primal highpass filter coefficients:
WaveletFilterCoefficients[HaarWavelet[], "PrimalHighpass"]WaveletFilterCoefficients[HaarWavelet[], "LiftingFilter", WorkingPrecision -> ∞]%[{"LiftingMatrixForm", z}]Generate function to compute lifting wavelet transform:
lf = WaveletFilterCoefficients[HaarWavelet[], "LiftingFilter", WorkingPrecision -> ∞]lf["ForwardLiftingFunction"][Range[8]]lf["InverseLiftingFunction"][%]Wavelet Transforms (5)
Compute a DiscreteWaveletTransform:
data = Table[Sin[t^2], {t, -3 π, 3 π, (6 π/1023)}];ListLinePlot[data, PlotRange -> All]dwt = DiscreteWaveletTransform[data, HaarWavelet[], 2]View the tree of wavelet coefficients:
dwt["TreeView"]Get the dimensions of wavelet coefficients:
dwt["Dimensions"]Plot the wavelet coefficients:
WaveletListPlot[dwt, PlotLayout -> "CommonXAxis"]HaarWavelet can be used to perform a DiscreteWaveletPacketTransform:
data = Table[Sin[t^2], {t, -3 π, 3 π, (6 π/1023)}];dwpt = DiscreteWaveletPacketTransform[data, HaarWavelet[], 2]View the tree of wavelet coefficients:
dwpt["TreeView"]Get the dimensions of wavelet coefficients:
dwpt["Dimensions"]Plot the wavelet coefficients:
WaveletListPlot[dwpt, PlotLayout -> "CommonXAxis"]HaarWavelet can be used to perform a StationaryWaveletTransform:
data = Table[Sin[t^2], {t, -3 π, 3 π, (6 π/1023)}];swt = StationaryWaveletTransform[data, HaarWavelet[], 2];View the tree of wavelet coefficients:
swt["TreeView"]Get the dimensions of wavelet coefficients:
swt["Dimensions"]Plot the wavelet coefficients:
WaveletListPlot[swt, PlotLayout -> "CommonXAxis"]HaarWavelet can be used to perform a StationaryWaveletPacketTransform:
data = Table[Sin[t^2], {t, -3 π, 3 π, (6 π/1023)}];swpt = StationaryWaveletPacketTransform[data, HaarWavelet[], 2];View the tree of wavelet coefficients:
swpt["TreeView"]Get the dimensions of wavelet coefficients:
swpt["Dimensions"]Plot the wavelet coefficients:
WaveletListPlot[swpt, PlotLayout -> "CommonXAxis"]HaarWavelet can be used to perform a LiftingWaveletTransform:
data = Table[Sin[t^2], {t, -3 π, 3 π, (6 π/1023)}];lwt = LiftingWaveletTransform[data, HaarWavelet[], 2];View the tree of wavelet coefficients:
lwt["TreeView"]Get the dimensions of wavelet coefficients:
lwt["Dimensions"]Plot the wavelet coefficients:
WaveletListPlot[lwt, PlotLayout -> "CommonXAxis"]Higher Dimensions (1)
Multivariate scaling and wavelet functions are products of univariate ones:
ϕ = WaveletPhi[HaarWavelet[]];
ψ = WaveletPsi[HaarWavelet[]];Table[Plot3D[Evaluate[f[x] g[y]], {x, -0.1, 1.1}, {y, -0.1, 1.1}, ExclusionsStyle -> {Orange, Opacity[0.5]}, Mesh -> None, Axes -> False, PlotStyle -> Orange], {f, {ϕ, ψ}}, {g, {ϕ, ψ}}]Applications (4)
Approximate a function using Haar wavelet coefficients:
data = Table[Abs[Sin[2 π x]] + 1.5 Abs[Cos[2 π x - π]], {x, 0, 1, (1/2^6 - 1)}];Perform a LiftingWaveletTransform:
dwd = LiftingWaveletTransform[data, HaarWavelet[]];Approximate original data by keeping
largest coefficients and thresholding everything else:
{data8, data16, data32} = Table[InverseWaveletTransform[WaveletThreshold[dwd, {"LargestCoefficients", n}, Automatic]], {n, {8, 16, 32}}];Compare the different approximations:
ListLinePlot[{data, data8, data16, data32}, PlotRange -> All]Compute the multiresolution representation of a signal containing an impulse:
data = Table[Sin[4 π t] + 2 Exp[-10^5 ((1/3) - t)^2], {t, 0, 1, (1/2^9)}];ListLinePlot[data]dwt = DiscreteWaveletTransform[data, HaarWavelet[], 4]WaveletListPlot[dwt, {{1}, {0, 1}, {0, 0, 1}, {0, 0, 0}}, PlotLayout -> "CommonXAxis", Method -> {"Inverse" -> True}]Compare the cumulative energy in a signal and its wavelet coefficients:
data = Table[Sin[2 π t], {t, 0, 1, (1/63)}];ListPlot[data]Compute the ordered cumulative energy in the signal:
cumulativeEnergy[data_] := Module[{c = Sort[Flatten[data]^2, Greater]}, (Accumulate[c]/Total[c])]ListPlot[cumulativeEnergy[data]]The energy in the signal is captured by relatively few wavelet coefficients:
dwd1 = LiftingWaveletTransform[data, HaarWavelet[], 1];dwd2 = LiftingWaveletTransform[data, HaarWavelet[], 2];ListPlot[{cumulativeEnergy[data], cumulativeEnergy[Last /@ dwd1[Automatic]], cumulativeEnergy[Last /@ dwd2[Automatic]]}, PlotStyle -> {Red, Blue, Orange}]Compare range and distribution of wavelet coefficients:
data = WeatherData["KMDZ", "MeanTemperature", {{2007, 1, 1}, {2007, 12, 31}, "Day"}];DateListPlot[data, Joined -> True]dwd = StationaryWaveletTransform[data["Values"], HaarWavelet[], 5];Plot distribution of wavelet coefficients:
BoxWhiskerChart[Join[{data["Values"]}, dwd[Automatic, "Values"]], ChartLabels -> Placed[Join[{"data"}, dwd["BasisIndex"]], Axis, Style[#, 12, Bold]&], BarOrigin -> Left, GridLines -> Automatic, ChartStyle -> "SolarColors"]Compare with wavelet coefficients plotted along a common
axis:
WaveletListPlot[dwd, PlotLayout -> "CommonYAxis"]Properties & Relations (15)
DaubechiesWavelet[1] is equivalent to HaarWavelet:
WaveletFilterCoefficients[HaarWavelet[]] === WaveletFilterCoefficients[DaubechiesWavelet[1]]Lowpass filter coefficients sum to unity;
:
Total[WaveletFilterCoefficients[HaarWavelet[], "PrimalLowpass"][[All, 2]]]Highpass filter coefficients sum to zero;
:
Total[WaveletFilterCoefficients[HaarWavelet[], "PrimalHighpass"][[All, 2]]]Scaling function integrates to unity;
:
Subsuperscript[∫, -∞, ∞]WaveletPhi[HaarWavelet[], x]ⅆxTable[Subsuperscript[∫, -∞, ∞]WaveletPhi[HaarWavelet[], (x/2^j)]ⅆx == 2^j, {j, 0, 4}]Haar scaling function is orthogonal to its shift;
:
With[{ϕ = WaveletPhi[HaarWavelet[]]}, Subsuperscript[∫, -∞, ∞]ϕ[x - i] ϕ[x - j]ⅆx]MatrixForm[Table[%, {i, -1, 1}, {j, -1, 1}]]Wavelet function integrates to zero;
:
Subsuperscript[∫, -∞, ∞]WaveletPsi[HaarWavelet[], x]ⅆxHaar wavelet function is orthogonal to its shift;
:
With[{ψ = WaveletPhi[HaarWavelet[]]}, Subsuperscript[∫, -∞, ∞]ψ[x - i] ψ[x - j]ⅆx]MatrixForm[Table[%, {i, -1, 1}, {j, -1, 1}]]Wavelet function is orthogonal to the scaling function at the same scale;
:
Subsuperscript[∫, -∞, ∞]WaveletPsi[HaarWavelet[], x] WaveletPhi[HaarWavelet[], x]ⅆxThe lowpass and highpass filter coefficients are orthogonal;
:
WaveletFilterCoefficients[HaarWavelet[], "PrimalLowpass"][[All, 2]].WaveletFilterCoefficients[HaarWavelet[], "PrimalHighpass"][[All, 2]]HaarWavelet has one vanishing moment;
:
With[{ψ = WaveletPsi[HaarWavelet[]]}, Table[Subsuperscript[∫, -∞, ∞]t^l ψ[t]ⅆt, {l, 0, 5}]]This means constant signals are fully represented in the scaling functions part ({0}):
dwt = DiscreteWaveletTransform[{2, 2, 2, 2}, HaarWavelet[], 1];InverseWaveletTransform[dwt, Automatic, {0}]Linear or higher-order signals are not:
dwt = DiscreteWaveletTransform[{1, 2, 3, 4}, HaarWavelet[], 1]InverseWaveletTransform[dwt, Automatic, {0}]
satisfies the recursion equation
:
ϕ = WaveletPhi[HaarWavelet[]];a = WaveletFilterCoefficients[HaarWavelet[], "PrimalLowpass"]Symbolically verify recursion:
Simplify[ϕ[t] == 2 Underoverscript[∑, i, 2]a[[i, 2]] ϕ[2 t - a[[i, 1]]]]Plot the components and the sum of the recursion:
scalet[t_, ϕ_, a_] := 2 Table[a[[i, 2]] ϕ[2 t - a[[i, 1]]], {i, Length[a]}]{Plot[Evaluate[scalet[t, ϕ, a]], {t, -0.5, 1.5}, ExclusionsStyle -> Dashed], Plot[Total[scalet[t, ϕ, a]], {t, -0.5, 1.5}, ExclusionsStyle -> Dashed]}
satisfies the recursion equation
:
ϕ = WaveletPhi[HaarWavelet[]];b = WaveletFilterCoefficients[HaarWavelet[], "PrimalHighpass"]Plot the components and the sum of the recursion:
wavelet[t_, ϕ_, b_] := 2 Table[b[[i, 2]] ϕ[2 t - b[[i, 1]]], {i, Length[b]}]{Plot[Evaluate[wavelet[t, ϕ, b]], {t, -0.5, 1.5}, ExclusionsStyle -> Dashed], Plot[Total[wavelet[t, ϕ, b]], {t, -0.5, 1.5}, ExclusionsStyle -> Dashed]}Frequency response for
is given by
:
h[wav_, ω_] := With[{a = WaveletFilterCoefficients[wav]}, Underoverscript[∑, i, Length[a]]a[[i, 2]] Exp[-I a[[i, 1]] ω]]The filter is a lowpass filter:
Plot[Abs[h[HaarWavelet[], ω]], {ω, -π, π}, Ticks -> {{-π, -(π/2), 0, (π/2), π}, Automatic}, AxesLabel -> {ω, Abs[H[ω]]}]Fourier transform of
is given by
:
h[wav_, ω_] := With[{a = WaveletFilterCoefficients[wav]}, Underoverscript[∑, i, Length[a]]a[[i, 2]] Exp[-I a[[i, 1]] ω]]fh[wav_, ω_, j_] := Abs[Underoverscript[∏, i, j]h[wav, (ω/2^i)]]Plot[fh[HaarWavelet[], ω, 10], {ω, -10 π, 10 π}, PlotRange -> All, AxesLabel -> {ω, Abs[Overscript[ϕ, ^ ][ω]]}]Frequency response for
is given by
:
g[wav_, ω_] := With[{b = WaveletFilterCoefficients[wav, "PrimalHighpass"]}, Underoverscript[∑, i, Length[b]]b[[i, 2]] Exp[-I b[[i, 1]] ω]]The filter is a highpass filter:
Plot[Abs[g[HaarWavelet[], ω]], {ω, -π, π}, Ticks -> {{-π, -(π/2), 0, (π/2), π}, Automatic}, AxesLabel -> {ω, Abs[G[ω]]}]Fourier transform of
is given by
:
h[wav_, ω_] := With[{a = WaveletFilterCoefficients[wav]}, Underoverscript[∑, i, Length[a]]a[[i, 2]] Exp[-I a[[i, 1]] ω]]g[wav_, ω_] := With[{b = WaveletFilterCoefficients[wav, "PrimalHighpass"]}, Underoverscript[∑, i, Length[b]]b[[i, 2]] Exp[-I b[[i, 1]] ω]]fg[wav_, ω_, j_] := Abs[g[wav, (ω/2)] Underoverscript[∏, i = 2, j]h[wav, (ω/2^i)]]Plot[fg[HaarWavelet[], ω, 10], {ω, -10 π, 10 π}, PlotRange -> All, AxesLabel -> {ω, Abs[Overscript[ψ, ^ ][ω]]}]Neat Examples (2)
Plot translates and dilations of scaling function:
ϕ[x_, j_, k_] := 2^j / 2 WaveletPhi[HaarWavelet[], 2^j x - k]Plot[Evaluate[Table[ϕ[x, j, 0], {j, 0, 4}]], {x, 0, 1}, Filling -> Axis]Plot[Evaluate[Table[ϕ[x, 2, k], {k, 0, 2^2 - 1}]], {x, 0, 1}, Filling -> Axis]Plot translates and dilations of wavelet function:
ψ[x_, j_, k_] := 2^j / 2 WaveletPsi[HaarWavelet[], 2^j x - k]Plot[Evaluate[Table[ψ[x, j, 0], {j, 0, 4}]], {x, 0, 1}, Filling -> Axis]Plot[Evaluate[Table[ψ[x, 2, k], {k, 0, 2^2 - 1}]], {x, 0, 1}, Filling -> Axis]Tech Notes
Related Guides
History
Text
Wolfram Research (2010), HaarWavelet, Wolfram Language function, https://reference.wolfram.com/language/ref/HaarWavelet.html.
CMS
Wolfram Language. 2010. "HaarWavelet." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HaarWavelet.html.
APA
Wolfram Language. (2010). HaarWavelet. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HaarWavelet.html
BibTeX
@misc{reference.wolfram_2026_haarwavelet, author="Wolfram Research", title="{HaarWavelet}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/HaarWavelet.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_haarwavelet, organization={Wolfram Research}, title={HaarWavelet}, year={2010}, url={https://reference.wolfram.com/language/ref/HaarWavelet.html}, note=[Accessed: 12-June-2026]}