zero value in beronoulli trials !!!
3 ビュー (過去 30 日間)
古いコメントを表示
Hi sir,I want to know,why some values in my program equal to zero
This is my program
N=10;
P=0.5;
for K=0:N;
format long e
M =exp((P)^K*((1-P)^N-K)*(factorial(N)/factorial(K)*factorial(N-K)))
display(M)
end
Thanks in advance
0 件のコメント
採用された回答
Andrew Newell
2011 年 4 月 10 日
The correct expression is
M =P.^K.*(1-P).^(N-K).*factorial(N)./(factorial(K).*factorial(N-K))
If you have the Statistics Toolbox, you can confirm that this gives the same output as
binopdf(0:N,N,P)
その他の回答 (2 件)
Oleg Komarov
2011 年 4 月 10 日
Some other parenthesis mistakes corrected:
N=10;
P=0.5;
K=0:N;
M =exp(P.^K.*(1-P).^(N-K).*factorial(N)./(factorial(K).*factorial(N-K)))
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!