jax.scipy.linalg.helmert

Contents

jax.scipy.linalg.helmert#

jax.scipy.linalg.helmert(n, full=False)[source]#

Construct a Helmert matrix.

JAX implementation of scipy.linalg.helmert().

The Helmert matrix has rows of orthonormal contrasts. For k = 1, ..., n - 1, row k - 1 is \((\underbrace{1, \ldots, 1}_{k}, -k, 0, \ldots, 0) / \sqrt{k(k + 1)}\). If full is True, a row of \(1 / \sqrt{n}\) is prepended.

Parameters:
  • n (int) – size of the matrix. Must be a positive integer.

  • full (bool) – if True, return the full (n, n) matrix; otherwise return only the (n - 1, n) contrast block. Defaults to False.

Returns:

A Helmert matrix of shape (n - 1, n) if full is False, or (n, n) if full is True.

Return type:

Array

Examples

>>> jax.scipy.linalg.helmert(2, full=True).round(3)
Array([[ 0.707,  0.707],
       [ 0.707, -0.707]], dtype=float32)