The two most common methods (in my experience) for comparing signals are the correlation and the mean squared error. Informally, if you imagine your signal as a point in some N-dimensional space (this tends to be easier if you imagine them as 3D points) then the correlation measures whether the points are in the same direction (from the "origin") and the mean squared error measures whether the points are in the same place (independent of the origin as long as both signals have the same origin). Which works better depends somewhat on the types of signal and noise in your system.
The MSE appears to be roughly equivalent to your example:
mse = 0;
for( int i=0; i<N; ++i )
mse += (x[i]-y[i])*(x[i]-y[i]);
mse /= N;
note however that this isn't really Pearson correlation, which would be more like
xx = 0;
xy = 0;
yy = 0;
for( int i=0; i<N; ++i )
{
xx += (x[i]-x_mean)*(x[i]-x_mean);
xy += (x[i]-x_mean)*(y[i]-y_mean);
yy += (y[i]-y_mean)*(y[i]-y_mean);
}
ppmcc = xy/std::sqrt(xx*yy);
given the signal means x_mean and y_mean. This is fairly close to the pure correlation:
corr = 0;
for( int i=0; i<N; ++i )
corr += x[i]*y[i];
however, I think the Pearson correlation will be more robust when the signals have a strong DC component (because the mean is subtracted) and are normalised, so a scaling in one of the signals will not cause a proportional increase in the correlation.
Finally, if the particular example in your question is a problem then you could also consider the mean absolute error (L1 norm):
mae = 0;
for( int i=0; i<N; ++i )
mae += std::abs(x[i]-y[i]);
mae /= N;
I'm aware of all three approaches being used in various signal and image processing applications, without knowing more about your particular application I couldn't say what would be likely to work best. I would note that the MAE and the MSE are less sensitive to exactly how the data is presented to them, but if the mean error is not really the metric you're interested in then they won't give you the results you're looking for. The correlation approaches can be better if you're more interested in the "direction" of your signal than the actual values involved, however it is more sensitive to how the data are presented and almost certainly requires some centring and normalisation to give the results you expect.
You might want to look up Phase Correlation, Cross Correlation, Normalised Correlation and Matched Filters. Most of these are used to match some sub-signal in a larger signal with some unknown time lag, but in your case you could just use the value they give for zero time lag if you know there is no lag between the two signals.
The matrix will be positive semi-definite if and only if $-1/(n-1) \le \alpha \le 1$, as shown in answers at Bound for the correlation of three random variables .
The upper bound of $n^2$ in $0 \leq \sum_{i=1}^{n} \sum_{j=1}^{n} r_{ij} \leq n^2 $ is achieved using $\alpha = 1.$
The lower bound of $0$ is achieved using $\alpha = -1/(n-1)$, because there are $n(n-1)$ occurrences of $\alpha$ in the double sum, together with n occurrences of $1$ (the diagonal elements). Therefore the double sum = $n(n-1)*(-1)/(n-1) + n*1 = 0$.
So what you state from the paper is consistent with the link I provided.
Best Answer
Arranging the correlations into a matrix: Let $\rho_{ij}$ be the correlation between variables $i$ and $j$. Place $\rho_{ij}$ into positions $(i,j)$ and $(j,i)$ of the correlation matrix. Note that $\rho_{ii}=1$, so place $1$'s down the diagonal. If the set of correlations is consistent, the matrix you have is a proper correlation matrix.
Sometimes (depending on how they were obtained), it turns out that the set of correlations doesn't form a proper correlation matrix. One way to check whether you do is to take the singular value decomposition and check all the singular values are non-negative.
[Such problems with a matrix that is "put together" are common. For example, pairwise correlation coefficients may have been generated from sets of observations where - due to partially missing observations, for example - different observation-pairs are available between different pairs of variables. If pairwise correlations are computed on all available data, sometimes the resulting correlation matrix is not positive semi-definite.]
If the constructed correlation matrix is not positive semi-definite, one simple approach to finding a valid correlation matrix near to the constructed one is to compute a singular-value decomposition and then set all negative singular values to zero, at which point you have the SVD of a correlation matrix which is often fairly close to the original. (There are alternatives, such as described at the link I gave in comments.)