Probability of Combinations Occurring

2 次查看(过去 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

回答(1 个)

the cyclist
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.

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by