How to group numeric variables in to single index

Hi,
I have below table contains three variables, each row represents a single observation, and I want to group them into single index. Kindly some one help how to group them in to single index.
4.82 0.3 10056
5.23 0.9 1235
4.98 0.85 125
9.65 0.46 4568
11.23 1.2 45689
5.98 0.78 46985
4.23 0.65 41256
4.32 1.1 2356
5.3 1.2 1815
1.25 3.1 1230
6.98 5.1 252
10.23 2.3 1236
2.6 0.59 142
Many thanks in advance,

댓글 수: 2

What should the grouping be? All of the values appear to be unique.
Yes, all 4 variables should be combined to see as a single index. So, each row represent a single value.

댓글을 달려면 로그인하십시오.

 채택된 답변

Walter Roberson
Walter Roberson 2016년 12월 23일
편집: Walter Roberson 2016년 12월 23일
A = [4.82 0.3 10056
5.23 0.9 1235
4.98 0.85 125
9.65 0.46 4568
11.23 1.2 45689
5.98 0.78 46985
4.23 0.65 41256
4.32 1.1 2356
5.3 1.2 1815
1.25 3.1 1230
6.98 5.1 252
10.23 2.3 1236
2.6 0.59 142];
A_grouped = mat2cell(A, ones(1, size(A,1)), 3);
Now A_grouped{1} will be the first row, A_grouped{2} will be the second row, and so on -- the rows would be grouped in a single index.
If this is not what you want, then you will need to show us a sample output.

댓글 수: 6

Hi,
My purpose is not to just physically merge (or group), I shown below:
Index=column3/(column1+column2) that will be
1964.1
201.5
21.4
451.8
3675.7
6950.4
8454.1
434.7
279.2
282.8
20.9
98.6
44.5
But this is a rough method, and it is dominated by the bigger value in that particular row. I want to know is there any efficient technique for this purpose, for example it may apply like boot strap method (OR pca) to identify the weightage of each variable in each row for each variable, finally combine the weightage to a single value (may be the summation of the weightage).
index = A(:,3) ./ (A(:,1) + A(:,2));
"But this is a rough method, and it is dominated by the bigger value in that particular row"
In each case you show, the largest value in each row is the third column. If at some point that is not true, then:
sA = sort(A, 2); %sort by row
index = sA(:,3) ./ (sA(:,1) + sA(:,2));
"I want to know is there any efficient technique for this purpose"
Possibly, but you are being very vague as to how you would like the data to be combined.
For example, are you trying to find the "best" coefficients P, Q, R, to combine your values using the formula ?
(P * column3) / ( (Q * column1 + R * column2) )
If you are, this can be simplified to
column3 / ( (q * column1 + r * column2) )
where q = Q/P and r = R/P; so it would be a matter of finding two coefficients instead of 3.
But you would need to say how you want the coefficients to behave. What would make one set of values "better" than a different set?
Your soultion is pretty good, Further, first can I perform PCA to identify which column is more dominating,and give the weightage acording to PCA analysis, and then group them,
Walter Roberson
Walter Roberson 2016년 12월 24일
편집: Walter Roberson 2016년 12월 24일
Possibly pca could be used for this situation, but I am not familiar enough with pca to understand how to use it.
What is the purpose of your proposed weighting? Are you trying to weight so that the two columns have equal "domination" ? Or are you trying to do "dimension reduction" ?
Yes Sir, dimention reduction in directly, but just give to give more weightage to the one which have highvariance.
V = var(A(:, 1:2));
output = A(:, 3) ./ sum( bsxfun( @mult, V, A(:,1:2)), 2);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by