フィルターのクリア

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

12 ビュー (過去 30 日間)
Onur Metin Mertaslan
Onur Metin Mertaslan 2020 年 5 月 5 日
コメント済み: KSSV 2020 年 5 月 5 日
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 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 5 月 5 日
編集済み: KALYAN ACHARJYA 2020 年 5 月 5 日
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 2020 年 5 月 5 日
Thanks a lot!

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2020 年 5 月 5 日
A = [1,1,2,3,5,5] ;
P = nnz(A==1)/length(A) % probability of 1
  2 件のコメント
Onur Metin Mertaslan
Onur Metin Mertaslan 2020 年 5 月 5 日
Thank you!
KSSV
KSSV 2020 年 5 月 5 日
Thanks is accepting the answer..;)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by