How can I assign a point from a matrix to a group in another matrix

3 vues (au cours des 30 derniers jours)
Whale Chicken
Whale Chicken le 2 Mai 2021
Modifié(e) : DGM le 3 Mai 2021
I have two matrixes, randMatrix and matrix1.
matrix1 is 150x5.
randMatrix consist of matrix1 values shuffled, they're the same numbers in different order.
In column 5 of matrix1 theres 50: 1s, 50: 2, and 50: 3s. Those numbers are in group 1 the first 50 numbers in matrix1, group 2 is the next 50 numbers and group 3 the remaining 50 numbers.
Each number in randMatrix is a point.
How can I know which corresponds to which number in randMatrix corresponds to group1, group2 and group3?
Heres matrix1
https://pastebin.com/a8N0x1ym
  2 commentaires
DGM
DGM le 2 Mai 2021
Modifié(e) : DGM le 2 Mai 2021
When you say the values are shuffled, is randMatrix a random permutation of matrix1's elements, or is it a random permutation of matrix1's row vectors?
When you say "Each number in randMatrix is a point" do you mean each individual element, or each row vector?
If it's a fully elementwise random permutation, I don't see how a unique mapping can be recovered unless you were in control of the process which randomized it. If it's a row-wise permutation, then it should be possible to figure out a mapping, provided the rows are unique.
Whale Chicken
Whale Chicken le 2 Mai 2021
When I say shuffled I mean that it’s a random permutation of matrix1 elements on both row and columns. It’s the same elements, just shuffled around. Each number in randMatrix is a point, meaning each individual element.

Connectez-vous pour commenter.

Réponse acceptée

DGM
DGM le 3 Mai 2021
Modifié(e) : DGM le 3 Mai 2021
The short answer is that you can't. If it's elementwise, I don't see that there is enough uniqueness between sets to determine any practial amount of mapping.
% I renamed the matrix M
% let's ignore col 5 since it's not unique anyway
A = M(1:50,1:4);
B = M(51:100,1:4);
C = M(101:150,1:4);
% these are values which are unique within each set
% i.e. after removing repeated values, this is how many would be left
% this already tells us that the intersectons are significant
um = unique(M); % 74/600 (12%) unique
ua = unique(A); % 45/200 (22.5%) unique (contains 1,3)
ub = unique(B); % 58/200 (29%) unique (contains 1,2,3)
uc = unique(C); % 53/200 (26.5%) unique (contains 2,3)
% this is how many of those values are a member of only one set
uniquetoa = numel(setdiff(setdiff(ua,ub),uc)) % 6/45 (13%)
uniquetob = numel(setdiff(setdiff(ub,ua),uc)) % 1/58 (1.7%)
uniquetoc = numel(setdiff(setdiff(uc,ub),ua)) % 8/53 (15%)
There is simply too much intersection between the sets. There are nearly two dozen unique numbers which are a member of all three sets. For instance, if you had a 1.5 in the permuted array, there would be no way to tell which set it originally came from. This intersection of sets A, B, and C constitutes a full 43% of M.
iabc = intersect(intersect(ua,ub),uc); % 23 values
miabc = ismember(M,iabc);
sum(miabc(:)) % 323/750 (43%)
If you can accept some lost information and want to recover as much of a mapping as you can, then you can probably see how far you can get:
% let's take a random permutation
Mp = M(randperm(numel(M)));
% look for membership
ia = ismember(Mp,ua);
ib = ismember(Mp,ub);
ic = ismember(Mp,uc);
% remove values which are ambiguous
% these are now maps identifying which elements
% unambiguously belong to which set
iau = ia & ~(ib | ic);
ibu = ib & ~(ia | ic);
icu = ic & ~(ib | ia);
sum(iau(:)) % 50 elements mapped
sum(ibu(:)) % 1 element mapped
sum(icu(:)) % 18 elements mapped
(50 + 1 + 18)/numel(Mp) % 9.2% mapped
<10% recovery doesn't seem very good to me.
  1 commentaire
Whale Chicken
Whale Chicken le 3 Mai 2021
This is close to what I was looking for. Thank you very much for your time and help :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by