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

12 次查看(过去 30 天)
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!

回答(1 个)

KSSV
KSSV 2020-5-5
A = [1,1,2,3,5,5] ;
P = nnz(A==1)/length(A) % probability of 1

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by