# Building a Dictionary Using PCA / SVD and Regenerating the Signals

I have the following problem and I know I can solve it using PCA / SVD, I just can get to write it properly.

I have many sensors, each produces M = 3500 samples of a signal.
The signal of each sensor is a little different from the other. I have N = 256 Sensors.

Now, I want to build a dictionary of those 256 Signals in a way that when I get a new 3500 Samples from a different sensor I will be able to calculate its coefficients and keep the only.
I want this signal to have K = 16 Parameters. Later, when I want to regenerate an approximation of this new signal, all I need is to multiply those coefficients by Dictionary / Base matrix.

I know how to do it an arbitrary Base $H$.
For instance, Using Fourier Series I can Have $H \in {R}^{16x3500}$.
Where each row of $H$ is a 3500 samples of an Harmonic Function with a given frequency.
This yields a dictionary which is given by the Pseudo Inverse ${\left({H}^{T}H \right)}^{-1}{H}^{T}$.
Namely, If I get new 3500 samples given by ${x}_{new}$, The coefficients are given by ${f}_{new} = {\left({H}^{T}H \right)}^{-1}{H}^{T} x$.
The approximation of ${x}_{new}$ is given by ${\hat{x}}_{new} = H {f}_{new}$.

Now, how can I get the optimal base for that using the PCA / SVD?
How do I get the new coefficients?
How do I approximate the "New Data"?

Thank You.

Found the solution,
Each new measurement is a signal with a given size - 3500 Samples.
Hence, it is a point in ${R}^{3500}$.

The data matrix has its signal in its rows.

Using the SVD and according to the PCA, the column of the Matrix $V$ spans this base (The rows of the data matrix) in a manner that each direction maximize the variance along that direction.

Hence the columns of the matrix $V$ should be selected according to the Singular Values (To keep the error minimal, take the 16 columns which relates to the 16 most significant Singular values).

If the number of taken vectors is less than 3500, they don't span the whole space, hence new measurements doesn't necessarily lie in this "Base / Dictionary" Range Space (Space which is spanned by its columns).
Hence the LS method should be used - $\hat{V} = V(:, 1:K)$ -> The way to calculate the coefficients of the new measurement is ${\left( {\hat{V}}^{H} \hat{V} \right )}^{-1} {\hat{V}}^{H} {x}_{new}$.

By the way, the coefficients of ${X}_{Data}$ are given by $U D$.
It can be shown by ${X}_{Data} = U D {V}^{H}$.
Since $V$ spans the whole space, no need for the LS solution and multiplying by ${V}^{H}$ is enough.
So ${X}_{Data} V = U D$ -> ${F}^{H} = UD$.