So i want to run an algorithm on my dataset, and the first step is the Singular Value Decomposition (SVD). I am basing it on an example i found on a book, and there they use MatLab and run SVD on this time series that has dimension 1xn. However, when I try to run it in python using the numpy.linalg.svd, this error always comes that the matrix needs to have at least 2xn dimension.
So my question is: how can I run SVD with an 1xn matrix (or a vector) without getting this error? Does anyone have an idea? It'd be very much apreciated :)
Now i know i could time stack this data matrix, but I first wanted to run it without doing this step to see what kind of eigenvalues I would get (and I know they would not accurately describe my data, but I still want to see exactly how).
In MATLAB everything is 2d (or more). In
numpy, arrays may be 1d. Keep that in mind when apply MATLAB examples to numpy.What exactly do you mean by
2xn dimension? To most numpy users that means a shape of (2,n), as opposed to (1,n) or (n,).When asking SO questions it's best to include actual code,and to quote the error exactly.
When I use
svdon a 3 element list, which becomes a (3,) array:`2xn dimension' is poor paraphrase of this error.
With a (1,3) argument:
and a (3,1):
If you already have a 1 dimensional array,
arr[:,None]orarr.reshape(-1,1)will change it to (n,1) shape.