How to check the proportionaly of columns of a complex rectagular matrix?
1 次查看(过去 30 天)
显示 更早的评论
I have a complex matrix G of size 45 x 2, where in magitude wise the 2nd column is very small than 1st.
Here in the code columns of G are created as shown in the code. the files g1 and t are attached here.
I am looking for a correct methodology to check if the columns are propotional in a complex rectagular matrix G?
clear all;
close all;
load g1.mat
load t.mat
G = [g1 -g1.*t];
0 个评论
采纳的回答
John D'Errico
2023-2-22
编辑:John D'Errico
2023-2-22
Checking if two vectors (in your case, just columns of a matrix) are proportional is pretty easy, as well as then computing the constant of proportionality. You need to be careful, as you cannot just test the correlation coefficient between the vectors, since it is trivial to have two distinct vectors that are not proportional at all, yet share a perfect correlation. For example given a vector x, the vectot y=1+x has a correlation coefficient of EXACTLY 1, yet they are not proportional.
load g1.mat
load t.mat
whos
t
plot(t)
Unfortunately, I think you misunderstand what can be done here, and even what proportional really means. g1 and g1.*t are NOT proportional to each other. You multutiplied g1 by the elements of another, non-constant vector t. Again, t is not constant. t varies dramatically over the elements of t, so that it even changes sign. So g1 is NOT proportional to g1.*t.
For example, consider the vector
x = [1:5]';
y = randn(5,1);
[x,y,x.*y]
Is there any possible reason to decide that x and x.*y are "proportional" to each other? NO.
Given all that, what can you do? You might decide to formulate the question, is there some SCALAR CONSTANT value s, such that given only the vectors g1 and g1.*t, without knowing the vector t, where we can approximate the second vector with the product g1*s?
Honestly, IF you knew the vector t, then
s = mean(t);
would arguably be what you would want to do. But you can try to estimate the SCALAR constant s. The best estimate is: given by the backslash operator:
g2 = g1.*t;
s_est = g1\g2
As you can see, since both g1 and g2 are complex valued, a tiny amount of an imaginary part has crept in, but that is just floating point trash.
A minor problem in this is that the larger values (in magnitude) of g1 become the ones that have the largest influence on the resulting estimate of s. So in fact, we will not find s_est as being the same as mean(t).
mean(t)
And then the pertinent question becomes, how close are the two vectors to being truly proportional? this is a valid question. We might compare the norm(g1*s - g2), then scaled by the norm of g1.
format long g
norm(g1*s_est - g2)/norm(g1)
That would give us some sort of meaure of how well we did. So a small number here is good. Or, perhaps we could formulate it in the form people often use, where R^2 near 1 is a good thing. So:
1 - norm(g1*s_est - g2)/norm(g1)
So you would say the model is aruably a decent one, that s_est is a decent approximation. Finally, you might decide to plot the two vectors.
plot(1:numel(g1),[g1*s_est,g2],'-o')
Perhaps the problem is you need to appreciate what proportionality means in context.
0 个评论
更多回答(1 个)
William Rose
2023-2-22
The correlation is a measure of the proportionality of two vectors. When the vectors are complex, the correlation is complex. The magnitude of the complex correlation is between 0 and 1 and is a reasonable measure of proportionality.
The code below displays the mean of each column, and it displays the complex correlation and the magnitude of the complex correlation.
load g1.mat
load t.mat
G = [g1 -g1.*t];
fprintf('G(:,1): mean=%.3e + i*%.3e\n',real(mean(G(:,1))),imag(mean(G(:,1))))
fprintf('G(:,2): mean=%.3e + i*%.3e\n',real(mean(G(:,2))),imag(mean(G(:,2))))
fprintf('Correlation = %.3f + i*%.3f\n',...
real(corr(G(:,1),G(:,2))),imag(corr(G(:,1),G(:,2))))
fprintf('Abs(corr)=%.3f\n',abs(corr(G(:,1),G(:,2))))
Good luck with your work.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Descriptive Statistics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!