nimble.calculate.leastSquaresSolution¶
- nimble.calculate.leastSquaresSolution(aObj, bObj)¶
Compute least-squares solution to equation A x = b.
Compute a vector x such that the 2-norm determinant of b - Ax is minimized. The matrix A may be square or rectangular (over-determined or under-determined).
- Parameters:
aObj ((M, N) nimble Base object.) – Left hand side object in A x = b.
bObj – Right-hand side nimble Base object in A x = b. (1-D)
- Returns:
xObj ((N) nimble Base object.) – Least-squares solution.
- Raises:
InvalidArgumentType – If
aObj
orbObj
is not a nimble Base Object. IfaObj
elements types are not supported.InvalidArgumentValue – If
bObj
is not a vector. 1-D.InvalidArgumentValueCombination – If
aObj
andbObj
have incompatible dimensions.
Examples
>>> a = [[0, 1], ... [1, 1], ... [2, 1], ... [3, 1], ... [4, 1]] >>> b = [6, 9, 12, 15, 18] >>> aObj = nimble.data(a) >>> bObj = nimble.data(b) >>> nimble.calculate.leastSquaresSolution(aObj, bObj) <Matrix 1pt x 2ft 0 1 ┌───────────── 0 │ 3.000 6.000 >