pinverse

Syntax

pinverse(X)

Arguments

X is a matrix.

Details

Calculate the pseudo-inverse matrix of X.

Return Value: a FAST DOUBLE MATRIX

Example

x=1..4$2:2;
x.pinverse()

col1

col2

-2 1.5
1 -0.5
y=1..8$2:4
y.pinverse(); 

col1

col2

-1 0.85
-0.5 0.45
0 0.05
0.5 -0.35
s1 = indexedSeries(2012.01.01..2012.01.04, [10, 20, 30, 40])
pinv(s1)

col1

col2

col3

col4

0.0033 0.0067 0.01 0.0133
m=matrix(1..10, 11..20)
m.rename!(2020.01.01..2020.01.10, `A`B);
m.setIndexedMatrix!()
pinv(m)

col1

col2

col3

col4

col5

col6

col7

col8

col9

col10

-0.0945 -0.0758 -0.057 -0.0382 -0.0194 -0.0006 0.0182 0.037 0.0558 0.0745
0.04 0.0333 0.0267 0.02 0.0133 0.0067 0 -0.0067 -0.0133 -0.02

For a matrix without a full rank, calculating the inverse will raise an error. The pseudo inverse can be calculated.

x=1 2 3 1 2 3$2:3
inverse(x) // Error: The argument of 'inverse' must be a square matrix.
pinverse(x)
col1 col2
-0.1067 0.2267
0.4133 -0.2533
-0.0667 0.2667

Related function: inverse