- Get the array
- Read the first element
- Count the repetitions of the first element
- pdf_first=repetitions/length(array)
How can I find the probability of each term in the array?
12 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
KALYAN ACHARJYA
el 5 de Mayo de 2020
Editada: KALYAN ACHARJYA
el 5 de Mayo de 2020
One Way:
Respuestas (1)
KSSV
el 5 de Mayo de 2020
A = [1,1,2,3,5,5] ;
P = nnz(A==1)/length(A) % probability of 1
2 comentarios
Ver también
Categorías
Más información sobre Multidimensional Arrays 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!