Residualise#

Residualise a tensor block via ordinary linear least squares.

Warning

When using torch, we have found in some cases that the least-squares fit returned was incorrect for reasons that are not clear. (Incorrect results are returned by torch.linalg.lstsq, although correct results are returned if torch.linalg.pinv is used instead.) Verify that results are reasonable when using this operation.

It is not clear whether the same is true for jax. Caution is advised.

Parameters#

rowvarbool (default True)

Indicates that the last axis of the input tensor is the observation axis and the penultimate axis is the variable axis. If False, then this relationship is transposed.

l2float (default 0.0)

L2 regularisation parameter. If non-zero, the least-squares solution will be regularised by adding a penalty term to the cost function.

return_modeLiteral[‘residual’, ‘orthogonal’] (default ‘residual’)

Indicates whether the residual or orthogonal tensor should be returned. The orthogonal tensor is the projection of Y onto the span of X (i.e., the least-squares solution).