Datalens.ai
← All algorithms

DECOMPOSITION

qr

Compute QR decomposition of a matrix.

Example of usage

Factorise a labelled industrial sensor calibration matrix and verify reconstruction.

Usage / limitations

+Use when: Fit least-squares models using numerically stable factorisation.

−Limitations: Matrix shape, symmetry, conditioning and numerical precision constrain validity.

Mathematical formula

A = QR.
Sample dataShow
{
  "variable": "measurement_matrix",
  "domain": "Industrial sensor calibration",
  "feature_names": [
    "temperature_c",
    "vibration_mm_s"
  ],
  "matrix": [
    [
      2.0,
      1.0
    ],
    [
      1.0,
      3.0
    ]
  ]
}

Code example (Python)

# DataLens.ai example
# Factorise the named two- or three-sensor calibration matrix.
from scipy.linalg import qr
Q,R = qr(A)
assert np.allclose(Q @ R,A) and np.allclose(Q.T @ Q,np.eye(2))
print("Expected output verified")