How to calculate the conditional proabability?

1 回表示 (過去 30 日間)
Ian Kavanagh
Ian Kavanagh 2019 年 11 月 7 日
回答済み: Jeff Miller 2019 年 11 月 7 日
I have a data set (attached) and I need to calculate the probability of non zero in row 2 given the event of a non zero in row 1 (I'm ignoring the dates). I'm struggling with the code for this. Can anyone help me?

回答 (1 件)

Jeff Miller
Jeff Miller 2019 年 11 月 7 日
Crude, but maybe illustrative:
all=readtable('RainTampa.txt','headerlines',31)
nonzeroVar2 = all(all.Var2~=0,:);
nonzeroVar2and3 = nonzeroVar2(nonzeroVar2.Var3~=0,:);
CondProb = height(nonzeroVar2and3) / height(nonzeroVar2)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by