Probability of Combinations Occurring
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
the cyclist
el 23 de Sept. de 2020
Editada: the cyclist
el 23 de Sept. de 2020
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 comentarios
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!