Probability of Combinations Occurring
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a 10000x2 double and I want to find all unique combinations and output the probabilty that each combination occurs. How would I go about this?
Thank you
댓글 수: 0
답변 (1개)
the cyclist
2020년 9월 23일
편집: the cyclist
2020년 9월 23일
By "unique combinations", I assume you mean unique rows.
Here is one way:
% Example dataset. (Use your data instead.)
x = [7 8;
1 3;
7 8;
1 2;
1 3;
1 3];
[uniqueRows,idxToUnique,idxFromUniqueBackToInput] = unique(x,'row','stable');
probabilityOfUniqueRows = histcounts(idxFromUniqueBackToInput,[1:max(idxFromUniqueBackToInput) Inf],'normalization','probability');
The output you need is uniqueRows and probabilityOfUniqueRows.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!