Creating a Helmert matrix using Scipy

The function helmert() from the scipy.linalg creates and returns a Helmert matrix of order n. The Helmert function is used in analysis of variance(ANOVA).

Linear Algebra Updated 29 May 2025 1 min read

Overview

  • A Helmert matrix is a square matrix of order n which is of the form

Helmert matrix

  • The SciPy function helmert() constructs and returns a Helmert matrix of order n.
  • A Helmet matrix is an orthogonal matrix. For an orthogonal matrix,its inverse is equal to its transpose.

Example

python
# Example Python program that creates a Helmert

            # matrix using the helmert() function from the scipy.linalg

            # module

import scipy.linalg as sclg

order = 5

            # Create a Helmert matrix

            helmertMatrix = sclg.helmert(5)

            print("Helmert matrix of order %d:"%order)

            print(helmertMatrix)

Output

Output
[[ 0.70710678 -0.70710678  0.          0.          0.        ]

             [ 0.40824829  0.40824829 -0.81649658  0.          0.        ]

             [ 0.28867513  0.28867513  0.28867513 -0.8660254   0.        ]

             [ 0.2236068   0.2236068   0.2236068   0.2236068  -0.89442719]]