Effacer les filtres
Effacer les filtres

How can I find the probability of each term in the array?

12 vues (au cours des 30 derniers jours)
Onur Metin Mertaslan
Onur Metin Mertaslan le 5 Mai 2020
Commenté : KSSV le 5 Mai 2020
Let's say we have an arrary such [1,1,2,3,5,5], how can I find the probability of the terms? I am quite new in Matlab and I could not solve the problem.
Thanks!
  2 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 5 Mai 2020
Modifié(e) : KALYAN ACHARJYA le 5 Mai 2020
One Way:
  • Get the array
  • Read the first element
  • Count the repetitions of the first element
  • pdf_first=repetitions/length(array)
Onur Metin Mertaslan
Onur Metin Mertaslan le 5 Mai 2020
Thanks a lot!

Connectez-vous pour commenter.

Réponses (1)

KSSV
KSSV le 5 Mai 2020
A = [1,1,2,3,5,5] ;
P = nnz(A==1)/length(A) % probability of 1
  2 commentaires
Onur Metin Mertaslan
Onur Metin Mertaslan le 5 Mai 2020
Thank you!
KSSV
KSSV le 5 Mai 2020
Thanks is accepting the answer..;)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Multidimensional Arrays 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