How to find a unique indicator of a specific matrix?

2 次查看(过去 30 天)
Can we find a unique indicator of a specific matrix?
for example, if there is the following matrix (generated by a specific case) , how can I find one indicator of it?
I tried to take the sumation of the absolute values of the Matrix, but it didnt work because it was similer or too close for other cases
M1 and M2 is the range that can the matrix M varies between them, they are generated from a one case but with a little variation in some parameters (I want to find indicator for each other and compare it with other cases)
in this case the indicator should be too close for these two matrices (they are generated from the same case)
M1 = [-0.321306015516281 -0.274347013364667 -0.244382392248534 -0.288238228952784;
0.0558620817276004 0.372558615192237 0.572777978587165 0.503058540034827;
0.879663610530521 -0.136530080441011 -0.146669343761813 -0.155051653631985;
-0.176098379345313 0.737213426291489 -0.317456953062300 -0.314726433029229;
-0.211259054671114 -0.342511568755319 0.574666860881602 -0.415568275258076;
-0.210220781888802 -0.326336514970413 -0.399587060803839 0.606679564783506]
M2 = [-0.329410894346382 -0.282164376523392 -0.250593904107229 -0.300770395163912;
0.0391745398039566 0.367487954611743 0.578801050109399 0.490318907952166;
0.880000126456464 -0.133241897165618 -0.141354513303187 -0.151019721814831;
-0.173510462331790 0.738010210780251 -0.318373231341420 -0.312738411276027;
-0.207557875879909 -0.344447577135199 0.568108475231932 -0.416369292422166;
-0.205833532679448 -0.322922994018591 -0.397620657310764 0.612493983612021]
  4 个评论
M
M 2023-2-8
any indicator, like one number represents a matrix ...
M
M 2023-2-8
@Les Beckham comparing by indicator is easier in this problem, because for each case there is a range

请先登录,再进行评论。

回答(2 个)

Walter Roberson
Walter Roberson 2023-2-8
  3 个评论
Walter Roberson
Walter Roberson 2023-2-8
No. All cases involving summarizing multiple values as a single value are mathematically classed as "hashing". Some hashing methods are better for particular purposes than other methods are, but all deterministic functions are classified as hash functions.
M
M 2023-2-8
编辑:M 2023-2-8
@Walter Roberson ok, but this method didnt work with my problem for example there is only slight difference between the above matrices and they should indicat for a case, as range for exapmle.. and any number between this range should indicate for the same case...

请先登录,再进行评论。


dpb
dpb 2023-2-8
移动:dpb 2023-2-8
Along @Les Beckham's thought process, perhaps <ismembertol> might be of some use...let's see
M1 = [-0.321306015516281 -0.274347013364667 -0.244382392248534 -0.288238228952784;
0.0558620817276004 0.372558615192237 0.572777978587165 0.503058540034827;
0.879663610530521 -0.136530080441011 -0.146669343761813 -0.155051653631985;
-0.176098379345313 0.737213426291489 -0.317456953062300 -0.314726433029229;
-0.211259054671114 -0.342511568755319 0.574666860881602 -0.415568275258076;
-0.210220781888802 -0.326336514970413 -0.399587060803839 0.606679564783506];
M2 = [-0.329410894346382 -0.282164376523392 -0.250593904107229 -0.300770395163912;
0.0391745398039566 0.367487954611743 0.578801050109399 0.490318907952166;
0.880000126456464 -0.133241897165618 -0.141354513303187 -0.151019721814831;
-0.173510462331790 0.738010210780251 -0.318373231341420 -0.312738411276027;
-0.207557875879909 -0.344447577135199 0.568108475231932 -0.416369292422166;
-0.205833532679448 -0.322922994018591 -0.397620657310764 0.612493983612021];
100*(M2-M1)./M1 % percentage difference
ans = 6×4
2.5225 2.8494 2.5417 4.3479 -29.8728 -1.3610 1.0516 -2.5324 0.0383 -2.4084 -3.6237 -2.6004 -1.4696 0.1081 0.2886 -0.6317 -1.7520 0.5652 -1.1413 0.1928 -2.0870 -1.0460 -0.4921 0.9584
tol0=1E-4; % set initial tolerance tightly...
N=numel(M1); % check for when all are outside tol
i=1;
t{i,1}=tol0;
n{i,1}=sum(ismembertol(M1,M2,t{i}),'all');
while n{i}<N
i=i+1;
t{i}=2*t{i-1};
n{i}=sum(ismembertol(M1,M2,t{i}),'all');
if i>10, break, end
end
semilogx(cell2mat(t),cell2mat(n),'x-','linewidth',1.5)
grid
You can 'spearmint with alternatives on max points or all or whatever suits....
We have no basis for any idea of what is/is not important here from which to judge.
  7 个评论
dpb
dpb 2023-2-8
Yeah, @Walter Roberson; I don't know why I tend to forget about nnz -- just 30-yr old habits die slowly, I guess, mostly. It's the better idiom; I should remember using it.
Walter Roberson
Walter Roberson 2023-2-8
A = [1 2 3]
A = 1×3
1 2 3
B = [18 42 17 3 14 11 (1+eps)]
B = 1×7
18.0000 42.0000 17.0000 3.0000 14.0000 11.0000 1.0000
[found, idx] = ismembertol(A,B)
found = 1×3 logical array
1 0 1
idx = 1×3
7 0 4
You can see from this that ismembertol() does not operate element-wise. Each member of the first matrix is compared to each element of the second matrix.
If you want to compare element-by-element then if all of the elements are in the same range, then
num_matches = nnz(abs(A-B) <= tolerance)
ismembertol() is for the case where each element of A is to be compared to all elements of B
When you do not pass a tolerance factor into ismembertol() then it uses 1e-12 (double) or 1e-6 (single) . If you use the datascale option you can specify a tolerance per column when ByRows option is used.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Preprocessing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by