Projecting Points to a new Basis

44 views (last 30 days)
Joshua on 24 Jun 2013
I'm probably missing something very fundamental here, but I'm not sure how to project a set of 520 coordinates in a 300-dimensional space to a new basis, A, which has dimensions 300 by n, n < 300.
I know that I can define the set of points to be a matrix B, dimensions 300 by 520. Then I can calculate for the projections using the equation when n = 1:
P = ((A * A') / (A' * A)) * B.
This works because A' * A is a singular value when n = 1 and thus the division can work. Is there a simple equation to calculate the projections of the points when n href = ""</a> 1?

Answers (2)

Roger Stafford
Roger Stafford on 24 Jun 2013
P = (A'*A)\(A'*B);
P will be an n by 520 matrix. Each column of P has the n components with respect to basis A of the corresponding column of B as projected orthogonally onto the subspace spanned by A. It is assumed here that A is a true basis of linearly independent columns, so that A'*A is non-singular.
  1 Comment
Roger Stafford
Roger Stafford on 25 Jun 2013
I think I should have explained yesterday's answer more thoroughly. The 512 n-element columns of the matrix P each consists of the linear coefficients for n corresponding columns of A which can be used to give the projected value of the corresponding column in B onto the space spanned by A columns. The 300-by-512 array P0 = A*P will have the projected values of corresponding vectors in B onto this space in terms of the original coordinates.
To give a concrete example, choose 3 instead of 300, 2 for n, and, say, 5 instead of 520. Then do this:
n = 2; m = 3; q = 5;
A = randn(m,n);
B = randn(m,q);
to form the two three-dimensional vectors as columns of A, and five 3D vectors as columns of B. Then write:
P = (A'*A)\(A'*B);
P0 = A*P;
P is a 2-by-5 array in which each column contains the two linear coefficients that would express the projection of the corresponding vector in B in terms of the two vectors in A. P0 is a 3-by-5 array which gives the actual coordinates of each of these projections in terms of the original coordinates.
You can check this out for, say, the third vector in B by:
a1 = A(:,1); a2 = A(:,2); % The two vectors of A
v = B(:,3); % The third vector of B
v1 = P0(:,3); % The projection of v onto space spanned by a1 and a2
v2 = v-v1; % v is decomposed into sum of projection and orthog. component
% Test that v2 vector is orthogonal to a1, a2, and v1
The very definition of P0 = A*P shows that P contains the described coefficients for vectors in A.

Sign in to comment.

Richard Brown
Richard Brown on 24 Jun 2013
Edited: Richard Brown on 24 Jun 2013
I'm not sure what your question is asking because you're missing a symbol off your question. But I think you mean if n is not equal to 1. Here's a method based on constructing a projector. Let's first set up the basis
n = 10;
A = rand(300, n);
I'm assuming your basis is linearly independent. Probably the nicest way is to orthonormalise the basis first and construct the projector P from it:
[Q, ~] = qr(A, 0);
P = Q*Q';
But you can skip that step if you want and construct P directly. However working with the matrix A'*A can lead to a badly conditioned problem
P = A*((A'*A)\A');
Projecting B is then easy
B = rand(300, 520);
Bproj = P*B;


Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!