Assign a set of weights to digits

1 view (last 30 days)
Good afternoon, everyone. Unfortunately, from time to time I block.
Here's the thing.
I have a set of digits where I have calculated how often each one appears.
Example,
Digit 1, appears 4x, digits 2 and 3 appear 1x, digit 4 appears 2x, and digits 5,6,7,8,9 appear 0 times. This in a matrix of values defined by 554 rows and 9 columns.
What I wanted was to assign a weight to each frequency for each row.
Example, the higher the frequency the lower the weight. In the example I gave, digit 1 would have a weight of 1, digits 2 and 3 would have a weight of 3, digit 4 would have a weight of 2, and the remaining digits would have a weight of 4. This for each row.
Can anyone help me? In the previous question I didn't answer earlier because I was sick.
1 2 3 4 5 6 7 8 9 - - - - - - -> this is the digits
4 1 1 2 0 0 0 0 0
3 1 1 2 0 0 1 0 0
1 5 1 0 0 1 0 0 0
5 3 0 0 0 0 0 0 0
3 2 1 0 0 0 0 1 1
3 2 1 1 0 0 0 1 0
3 2 0 1 0 0 1 1 0
4 2 0 0 0 1 0 1 0
2 3 1 0 2 0 0 0 0
2 1 2 1 1 0 0 1 0
2 2 1 0 1 1 0 0 1
2 4 0 0 1 0 0 1 0
3 2 1 1 0 0 1 0 0
4 1 1 0 0 0 1 1 0
4 2 1 0 0 1 0 0 0
5 0 2 0 0 0 1 0 0
2 2 2 0 1 0 1 0 0
3 4 0 0 0 0 1 0 0
2 4 0 0 0 0 0 2 0
5 0 2 0 0 0 1 0 0
5 2 1 0 0 0 0 0 0
4 1 1 1 0 0 1 0 0
3 2 1 0 0 1 0 0 1
5 0 2 0 0 0 1 0 0
2 3 2 0 0 0 0 1 0
4 2 0 0 0 0 1 1 0
2 0 4 1 0 0 0 1 0
3 3 0 0 0 0 1 1 0
5 0 2 0 0 0 1 0 0
4 1 2 0 0 0 0 0 1
5 2 0 0 0 0 1 0 0
5 0 2 0 0 0 1 0 0
5 2 1 0 0 0 0 0 0
4 2 1 0 0 0 1 0 0
5 0 2 0 0 0 1 0 0
3 3 1 1 0 0 0 0 0
4 0 3 0 0 0 1 0 0
3 3 0 1 1 0 0 0 0
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4 0 1 2 1 0 0 0 0
2 2 3 0 1 0 0 0 0
0 2 3 0 0 1 2 0 0
2 2 1 0 0 0 3 0 0
The above figures already reflect the frequency with which they occur..
  2 Comments
the cyclist
the cyclist on 2 Mar 2023
It seems strange to me that if your input row is
in = [4 3 3 3 3 3 3 4 4]
that your output row would be
out = [1 1 1 1 1 1 1 1 1];
The weight is equal to 1 in two different cases:
  • the value is equal to the maximum
  • the value is 1 less than the maximum
You really don't need to distinguish between those two cases?
Voss
Voss on 2 Mar 2023
If I'm interpreting the original question correctly, the output for
in = [4 3 3 3 3 3 3 4 4]
would be
out = [1 2 2 2 2 2 2 1 1]

Sign in to comment.

Accepted Answer

Voss
Voss on 2 Mar 2023
load('counts.mat')
disp(counts);
4 1 1 2 0 0 0 0 0 3 1 1 2 0 0 1 0 0 1 5 1 0 0 1 0 0 0 5 3 0 0 0 0 0 0 0 3 2 1 0 0 0 0 1 1 3 2 1 1 0 0 0 1 0 3 2 0 1 0 0 1 1 0 4 2 0 0 0 1 0 1 0 2 3 1 0 2 0 0 0 0 2 1 2 1 1 0 0 1 0 2 2 1 0 1 1 0 0 1 2 4 0 0 1 0 0 1 0 3 2 1 1 0 0 1 0 0 4 1 1 0 0 0 1 1 0 4 2 1 0 0 1 0 0 0 5 0 2 0 0 0 1 0 0 2 2 2 0 1 0 1 0 0 3 4 0 0 0 0 1 0 0 2 4 0 0 0 0 0 2 0 5 0 2 0 0 0 1 0 0 5 2 1 0 0 0 0 0 0 4 1 1 1 0 0 1 0 0 3 2 1 0 0 1 0 0 1 5 0 2 0 0 0 1 0 0 2 3 2 0 0 0 0 1 0 4 2 0 0 0 0 1 1 0 2 0 4 1 0 0 0 1 0 3 3 0 0 0 0 1 1 0 5 0 2 0 0 0 1 0 0 4 1 2 0 0 0 0 0 1 5 2 0 0 0 0 1 0 0 5 0 2 0 0 0 1 0 0 5 2 1 0 0 0 0 0 0 4 2 1 0 0 0 1 0 0 5 0 2 0 0 0 1 0 0 3 3 1 1 0 0 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4 1 1 2 0 0 0 0 0
3 1 1 2 0 0 1 0 0
1 5 1 0 0 1 0 0 0];
% If you want the weight of each element to be the difference from the row
% maximum
W1 = max(M,[],2) - M
W1 = 3×9
0 3 3 2 4 4 4 4 4 0 2 2 1 3 3 2 3 3 4 0 4 5 5 4 5 5 5
% If you want the weight of each element to be the difference from the row
% maximum, except you want 1 for actual max (which is what you described)
W2 = max(M,[],2) - M + (M==max(M,[],2))
W2 = 3×9
1 3 3 2 4 4 4 4 4 1 2 2 1 3 3 2 3 3 4 1 4 5 5 4 5 5 5

Community Treasure Hunt

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

Start Hunting!