Hadamard transform

(1, 0, 1, 0, 0, 1, 1, 0) × H(8) = (4, 2, 0, −2, 0, 2, 0, 2)


The Hadamard transform (also known as the Walsh–Hadamard transform, Hadamard–Rademacher–Walsh transform, Walsh transform, or Walsh–Fourier transform) is an example of a generalized class of Fourier transforms. It performs an orthogonal, symmetric, involutive, linear operation on a tuple of 2m numbers.
The Hadamard transform can be regarded as being built out of size-2 discrete Fourier transforms (DFTs), and is in fact equivalent to a multidimensional DFT of size 2 × 2 × ⋯ × 2 × 2.[2] It decomposes an arbitrary input vector into a superposition of Walsh functions.
The transform is named for the French mathematician Jacques Hadamard (French: [adamaʁ]), the German-American mathematician Hans Rademacher, and the American mathematician Joseph L. Walsh.
Definition
[edit]The Hadamard transform Hm is a 2m × 2m matrix, the Hadamard matrix (scaled by a normalization factor), that transforms 2m real numbers xn into 2m real numbers Xk. The Hadamard transform can be defined in two ways: recursively, or by using the binary (base-2) representation of the indices n and k.
Recursively, we define the 1 × 1 Hadamard transform H0 by the identity H0 = 1, and then define Hm for m > 0 by: where the division by 2m/2 is a normalization that is sometimes omitted.
For m > 1, we can also define Hm by: where represents the Kronecker product. Thus, other than this normalization factor, the Hadamard matrices are made up entirely of 1 and −1.
Equivalently, we can define the Hadamard matrix by its (k, n)-th entry by writing
where the kj and nj are the bit elements (0 or 1) of k and n, respectively. Note that for the element in the top left corner, we define: . In this case, we have:
This is exactly the multidimensional DFT, normalized to be unitary, if the inputs and outputs are regarded as multidimensional arrays indexed by the nj and kj, respectively.
Some examples of the Hadamard matrices follow. where is the bitwise dot product of the binary representations of the numbers i and j. For example, if , then , agreeing with the above (ignoring the overall constant). Note that the first row, first column element of the matrix is denoted by .
H1 is precisely the size-2 DFT. It can also be regarded as the Fourier transform on the two-element additive group of Z/(2).
The rows of the Hadamard matrices are the Walsh functions.
This section is missing information about ordering variants of the Hadamard matrices: sequency (Walsh matrix), Hadamard, and dyadic. (April 2024) |
Relation to Fourier transform
[edit]The Hadamard transform is equivalent to a multidimensional DFT of size 2 × 2 × ⋯ × 2 × 2.[2]
Formally, the Hadamard transform is a Fourier transform on the Boolean group .[3] [4] Using the Fourier transform on finite (abelian) groups, the Fourier transform of a function is the function defined by where is a character of . Each character has the form for some , where the multiplication is the boolean dot product on bit strings, so we can identify the input to with (Pontryagin duality) and define by
This is the Hadamard transform of , considering the input to and as boolean strings.
In terms of the above formulation where the Hadamard transform multiplies a vector of complex numbers on the left by the Hadamard matrix the equivalence is seen by taking to take as input the bit string corresponding to the index of an element of , and having output the corresponding element of .
The usual discrete Fourier transform, applied to a vector of complex numbers, instead uses characters of the cyclic group . Consequently the DFT requires substantially more complicated arithmetic than the Hadamard transform. Unlike the DFT, the Hadamard transform is purely real, and in fact requires no multiplication, only sign flips.
Computational complexity
[edit]In the classical domain, the Hadamard transform can be computed in operations (), using the fast Hadamard transform algorithm.
In the quantum domain, the Hadamard transform can be computed in time, as it is a quantum logic gate that can be parallelized.
Quantum computing applications
[edit]The Hadamard transform is used extensively in quantum computing. The 2 × 2 Hadamard transform is the quantum logic gate known as the Hadamard gate, and the application of a Hadamard gate to each qubit of an -qubit register in parallel is equivalent to the Hadamard transform .
Hadamard gate
[edit]In quantum computing, the Hadamard gate is a one-qubit rotation, mapping the qubit-basis states and to two superposition states with equal weight of the computational basis states and . Usually the phases are chosen so that
in Dirac notation. This corresponds to the transformation matrix in the basis, also known as the computational basis. The states and are known as and respectively, and together constitute the polar basis in quantum computing.
Hadamard gate operations
[edit]
One application of the Hadamard gate to either a 0 or 1 qubit will produce a quantum state that, if observed, will be a 0 or 1 with equal probability (as seen in the first two operations). This is exactly like flipping a fair coin in the standard probabilistic model of computation. However, if the Hadamard gate is applied twice in succession (as is effectively being done in the last two operations), then the final state is always the same as the initial state.
Hadamard transform in quantum algorithms
[edit]Computing the quantum Hadamard transform is simply the application of a Hadamard gate to each qubit individually because of the tensor product structure of the Hadamard transform. This simple result means the quantum Hadamard transform requires operations, compared to the classical case of operations.
For an -qubit system, Hadamard gates acting on each of the qubits (each initialized to the ) can be used to prepare uniform quantum superposition states when is of the form . In this case with qubits, the combined Hadamard gate is expressed as the tensor product of Hadamard gates:
The resulting uniform quantum superposition state is then: This generalizes the preparation of uniform quantum states using Hadamard gates for any .[5]
Measurement of this uniform quantum state results in a random state between and .
Many quantum algorithms use the Hadamard transform as an initial step, since as explained earlier, it maps n qubits initialized with to a superposition of all 2n orthogonal states in the basis with equal weight. For example, this is used in the Deutsch–Jozsa algorithm, Simon's algorithm, the Bernstein–Vazirani algorithm, and in Grover's algorithm. Note that Shor's algorithm uses both an initial Hadamard transform, as well as the quantum Fourier transform, which are both types of Fourier transforms on finite groups; the first on and the second on .
Preparation of uniform quantum superposition states in the general case, when ≠ is non-trivial and requires more work. An efficient and deterministic approach for preparing the superposition state with a gate complexity and circuit depth of only for all was recently presented.[6] This approach requires only qubits. Importantly, neither ancilla qubits nor any quantum gates with multiple controls are needed in this approach for creating the uniform superposition state .
Convolutional neural networks
[edit]The Hadamard transform has found applications in quantum machine learning, particularly in hybrid quantum-classical neural networks. Dyadic convolution between two vectors is equivalent to element-wise multiplication of their Hadamard transform representations; thus convolutional layers can be performed efficiently by taking the Hadamard transform, multiplying, and then inverting the Hadamard transform. While classical computation of the Hadamard transform requires O(n log n) operations using the fast Hadamard transform algorithm, the quantum implementation can compute the transform in O(1) time by applying Hadamard gates to all qubits simultaneously.[7]
Application in evolutionary biology
[edit]The Hadamard transform can be used to estimate phylogenetic trees from molecular data.[8][9][10] In principle, the Hadamard transform can be applied to many different models of sequence evolution, but the case of greatest interest uses data from nucleic acids (NAs).[8][11]
Formally, consider the four possible strand nucleobases as elements of the Klein 4-group V acting on itself. One C2 axis corresponds to transitions and the other to transversions. NA sequences of length k are elements of Vk, and a given index into these length-k sequences is called a site. A phylogenetic tree T is a tree, rooted at some r, in which each point has been identified with a NA sequence.[12]
In biological applications, one would like to specify mutation rates for each edge of T and then compute the resulting probability of observing T. Ideally, this process should be easily invertible, such that an optimization algorithm can find a (tree, mutation rate) pair producing the observed DNA sequences with maximum likelihood. In fact, this can be done with the Hadamard transform, as follows.[12][13]
Let I be the power set of T\{r}, and consider the following I2-indexed vector x. Each site j determines a σ1∈I, the set of points with a transition relative to r at site j. Likewise transversions determine another σ2∈I for each site. Then x(σ1,σ2) is the proportion (out of {1,...,k}) of sites determining (σ1,σ2).[12]
The linear operator H:ℝI2→ℝI2 with (σ,τ)th coefficient (−1)|σ1∩τ1|+|σ2∩τ2| is a Hadamard matrix; in fact, it defines a Hadamard transform when I is enumerated in a certain order.[9] Let
- γ = H−1 log⊗I2(Hx)
where the ⊗I2 indicates that the logarithm acts on each component of the vector. Then γ is almost the mutation rates m necessary to produce the observed probability distribution x, as follows.[12][14]
For the full Kimura model, with all 4 nucleic acids distinguished, there are three free parameters for each edge. Converting these values to the corresponding entry in γ requires conjugation of another logarithm with a 3×3 matrix.[12]
If the sequences are instead RY-coded, then the relationship is much simpler. In that case, x and γ are indexed by I (rather than I2), as can m be: for even-sized σ∈I, let E(σ)=σ; for odd-sized σ∈I, let E(σ)=σ⊔{r}; and let mσ be the mutation rate on the edge disconnecting σ from the rest of T. (m is not quite a measured quantity, as it includes the probability of reverted mutations. It is related to the observed probability of character change via
- mσ=−1/2log(1-2pσ)
where p is the observed probability.) Then γ=m.[9]
This technique can also be generalized to the case in which different sites mutate at different rates.[15]
In all cases, the time complexity of determining the tree is dominated by the Hadamard transform, which takes O(|T|2|T|)-many steps.[16] However, algorithms can reconstruct the tree by piecing together smaller trees constructed from a subset of T.[17]
Other applications
[edit]The Hadamard transform is also used in data encryption, as well as many signal processing and data compression algorithms, such as JPEG XR and MPEG-4 AVC. In video compression applications, it is usually used in the form of the sum of absolute transformed differences. It is also a crucial part of significant number of algorithms in quantum computing. The Hadamard transform is also applied in experimental techniques such as NMR, mass spectrometry and crystallography. It is additionally used in some versions of locality-sensitive hashing, to obtain pseudo-random matrix rotations.
See also
[edit]External links
[edit]- Ritter, Terry (August 1996). "Walsh–Hadamard Transforms: A Literature Survey".
- Akansu, Ali N.; Poluri, R. (July 2007). "Walsh-Like Nonlinear Phase Orthogonal Codes for Direct Sequence CDMA Communications" (PDF). IEEE Transactions on Signal Processing. 55 (7): 3800–6. Bibcode:2007ITSP...55.3800A. doi:10.1109/TSP.2007.894229. S2CID 6830633.
- Pan, Jeng-shyang Data Encryption Method Using Discrete Fractional Hadamard Transformation (May 28, 2009)
- Lachowicz, Dr. Pawel. Walsh–Hadamard Transform and Tests for Randomness of Financial Return-Series (April 7, 2015)
- Beddard, Godfrey; Yorke, Briony A. (January 2011). "Pump-probe Spectroscopy using Hadamard Transforms" (PDF). Archived from the original (PDF) on 2014-10-18. Retrieved 2012-04-28.
- Yorke, Briony A.; Beddard, Godfrey; Owen, Robin L.; Pearson, Arwen R. (September 2014). "Time-resolved crystallography using the Hadamard transform". Nature Methods. 11 (11): 1131–1134. doi:10.1038/nmeth.3139. PMC 4216935. PMID 25282611.
References
[edit]- ↑ Compare Figure 1 in Townsend, W.J.; Thornton, M.A. (2001). "Walsh spectrum computations using Cayley graphs". Proceedings of the 44th IEEE 2001 Midwest Symposium on Circuits and Systems (MWSCAS 2001). MWSCAS-01. Vol. 1. IEEE. pp. 110–113. doi:10.1109/mwscas.2001.986127. ISBN 0-7803-7150-X.
- 1 2 Kunz, H.O. (1979). "On the Equivalence Between One-Dimensional Discrete Walsh–Hadamard and Multidimensional Discrete Fourier Transforms". IEEE Transactions on Computers. 28 (3): 267–8. doi:10.1109/TC.1979.1675334. S2CID 206621901.
- ↑ Fourier Analysis of Boolean Maps– A Tutorial –, pp. 12–13
- ↑ Lecture 5: Basic quantum algorithms, Rajat Mittal, pp. 4–5
- ↑ Nielsen, Michael A.; Chuang, Isaac (2010). Quantum Computation and Quantum Information. Cambridge: Cambridge University Press. ISBN 978-1-10700-217-3. OCLC 43641333.
- ↑ Alok Shukla and Prakash Vedula (2024). "An efficient quantum algorithm for preparation of uniform quantum superposition states". Quantum Information Processing. 23:38 (1): 38. arXiv:2306.11747. Bibcode:2024QuIP...23...38S. doi:10.1007/s11128-024-04258-4.
- ↑ Hongyi Pan; Xin Zhu; Salih Furkan Atici; Ahmet Enis Cetin (2023). A Hybrid Quantum-Classical Approach based on the Hadamard Transform for the Convolutional Layer. International Conference on Machine Learning. Vol. 202. PMLR. pp. 26891–26903. arXiv:2305.17510.
- 1 2 Székely, L. A.; Steel, M. A.; Erdős, P. L. "Fourier calculus on evolutionary trees". Advances in Applied Mathematics. 14: 212–215.
{{cite journal}}: CS1 maint: multiple names: authors list (link) CS1 maint: numeric names: authors list (link) - 1 2 3 Hendy, Michael D.; Penny, David (January 1993). "Spectral analysis of phylogenetic data". Journal of Classification. 10 (1): 5–24. doi:10.1007/BF02638451. ISSN 0176-4268. S2CID 122466038.
- ↑ McBee, Cayla D. (13 May 2010). Some Topics in Combinatorial Phylogenetics (PhD).
- ↑ Farach, Martin; Kannan, Sampath (July 1999). "Efficient algorithms for inverting evolution". Journal of the ACM. 46 (4): 437–449. doi:10.1145/320211.320212.
- 1 2 3 4 5 Steel, M. A.; Hendy, M. D.; Székely, L. A.; Erdős, Pal L. (1992) [June 1992]. "Spectral analysis and closest tree method for genetic sequences". Applied Math Letters. 5 (6). Great Britain: Pergamon: 63–67.
{{cite journal}}: CS1 maint: multiple names: authors list (link) CS1 maint: numeric names: authors list (link) - ↑ Hendy, M. D.; Penny, D.; Steel, M. A. (1994-04-12). "A discrete Fourier analysis for evolutionary trees". Proceedings of the National Academy of Sciences. 91 (8): 3339–3343. Bibcode:1994PNAS...91.3339H. doi:10.1073/pnas.91.8.3339. ISSN 0027-8424. PMC 43572. PMID 8159749.
- ↑ Bryant, David (2009) [11 December 2007]. "Hadamard phylogenetic methods and the n-taxon process". Bulletin of Mathematical Biology. 71. Springer: 339–351. doi:10.1007/s11538-008-9364-8.
- ↑ Waddell, Peter J.; Penny, David; Moore, Terry (1997). "Hadamard conjugations and modeling sequence evolution with unequal rates across sites". Molecular Phylogenetics and Evolution. 8 (1 (August)): 33–50. FY970405.
- ↑ Hendy, Michael D.; Charleston, Michael A. (1993). "Hadamard conjugation: a versatile tool for modelling nucleotide sequence evolution". New Zealand Journal of Botany. 31. Royal Society of New Zealand: 236–237. doi:10.1080/0028825X.1993.10419500.
- ↑ Székely, L. A.; Erdős, P. L.; Steel, M. A. "The combinatorics of reconstructing evolutionary trees". § Conclusion.
{{cite journal}}: Cite journal requires|journal=(help)CS1 maint: multiple names: authors list (link) CS1 maint: numeric names: authors list (link)