Effacer les filtres
Effacer les filtres

Get the probability of a matrices

1 vue (au cours des 30 derniers jours)
fyza affandi
fyza affandi le 15 Déc 2018
Modifié(e) : madhan ravi le 15 Déc 2018
I have a matrix E1
1 1 4 5 1 1 3 1
1 1 2 5 1 1 1 1
3 4 1 3 5 10 5 4
4 2 3 4 5 8 4 1
1 2 12 16 1 1 3 3
1 2 10 14 1 1 1 1
1 1 10 8 2 5 3 15
5 2 1 3 2 21 1 11
I sort the symbols into a table
%calculate the freq%
[a,b]=hist(E1,unique(E1));
out=[b' sum((a),2)];
%Sorting into table%
Table = array2table(out,'VariableNames',{'Symbol','Count'})
%Rearrange table in descending order%
tblB = sortrows(Table,{'Count'},{'descend'})
And the result turns into this
Symbol Count
______ _____
1 25
3 8
2 7
5 7
4 6
10 3
8 2
11 1
12 1
14 1
15 1
16 1
21 1
So my question is how can I get the probabilities of each symbols in vector?
The desired result is as below
mat=[0.3906 0.125 0.1094 0.1094 0.0938 0.0469 0.0313 0.0156 0.0156 0.0156 0.0156 0.0156 0.0156];

Réponse acceptée

madhan ravi
madhan ravi le 15 Déc 2018
mat=tblB.Symbol./sum(tblB.Count) %though the pattern is not discernible
  2 commentaires
fyza affandi
fyza affandi le 15 Déc 2018
Thank you.
After some corrections , I get the answer.
mat=[];
for matz=1:height(tblB)
mat=[mat,tblB.Count(matz)/sum(tblB.Count)]
end
madhan ravi
madhan ravi le 15 Déc 2018
Modifié(e) : madhan ravi le 15 Déc 2018
Anytime :) , if my answer helped you make sure to accept the answer.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by