All, I've looked at the following answer and it all looks good.
Matrix multiplication, solve Ax = b solve for x
I must be doing something wrong though if I work out the problem by hand I'm getting a different solution.
Method 1:
A = [[0,1,0],
[0,0,1],
[.5,.5,0]]
b = [1,1,1]
x = numpy.linalg.lstsq(A,b)
x
yields
(array([ 1., 1., 1.]),
array([], dtype=float64),
3,
array([ 1.14412281, 1. , 0.43701602]))
Method 2 (As suggested by Kevin below I transposed the matrix):
A = [[0,0,.5],[1,0,.5],[0,1,0]]
b = [1,1,1]
x = numpy.linalg.lstsq(A,b)
x
yields
(array([ 0., 1., 2.]),
array([], dtype=float64),
3,
array([ 1.14412281, 1. , 0.43701602]))
If I work out Ax=b by hand I get x = 1/5*[1,2,2]. Note that I am working example 11.19 from the link below:
https://www.probabilitycourse.com/chapter11/11_3_2_stationary_and_limiting_distributions.php
What am I missing?
If I follow the example on this link: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.solve.html
3x+y=9
x+2y=8
[x,y]=[2,3]
I do get the right solution if I do it with python or by hand. Any pointers? I must be missing something very simple here