Python Forum
Inaccurate result when a vector is divided by a matrix
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inaccurate result when a vector is divided by a matrix
#4
Ok,
if you try to execute the following code
import numpy as np
a = np.array([10, 10, 10])
b = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]])
a @ np.linalg.pinv(b)
you get
Output:
array([0.71428571, 1.42857143, 2.14285714])
np.linalg.pinv(x) returns Moore-Penrose inversion of a matrix x. x @ y denotes matrix product between x and y. Moore-Penrose inversion is used to obtain least squares solution for over-determined (or under-determined) linear systems. Octave knows: if you are trying to divide one matrix onto another, you are likely trying to solve system of linear equations. E.g.: Ax=b, then x = b / A; in Python you should do this: x = np.linalg.pinv(A) @ b.
Reply


Messages In This Thread
RE: Inaccurate result when a vector is divided by a matrix - by scidam - Oct-29-2019, 12:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Check if two matrix are equal and of not add the matrix to the list quest 3 884 Jul-10-2023, 02:41 AM
Last Post: deanhystad
Question How to understand the vector/direction mason321 0 1,139 Dec-14-2021, 10:57 PM
Last Post: mason321
  How to find vector of a 3D plot mason321 0 1,038 Nov-13-2021, 05:05 PM
Last Post: mason321
  How to multiply a matrix with herself, until the zero matrix results peanutbutterandjelly 3 3,405 May-03-2021, 06:30 AM
Last Post: Gribouillis
  How do I make a symmetric matrix from a column vector? leocsmith 3 3,727 Mar-30-2021, 10:17 AM
Last Post: leocsmith
  3D vector class with inheritance from 2D vector class buss0140 4 3,204 Dec-20-2020, 08:44 PM
Last Post: deanhystad
  Sume Every 10 element in the list and Divided of Sum quest_ 7 3,152 Nov-27-2020, 10:58 AM
Last Post: perfringo
  Issue with def norm in class Vector DimosG 4 2,522 Mar-26-2020, 05:03 PM
Last Post: DimosG
  Return all Values which can divided by 9 lastyle 2 1,866 Mar-16-2020, 09:22 PM
Last Post: lastyle
  Problem in creating a vector termo 11 4,012 Oct-10-2019, 03:09 PM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020