zero value in beronoulli trials !!!

조회 수: 3 (최근 30일)
reem
reem 2011년 4월 10일
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

채택된 답변

Andrew Newell
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)
  댓글 수: 1
reem
reem 2011년 4월 10일
Thank you so so much Oleg and Andrew
I will not forget your help forever
Kind regards

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Oleg Komarov
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)))
  댓글 수: 1
reem
reem 2011년 4월 10일
Thank you so much Oleg
I hope all best thing for you

댓글을 달려면 로그인하십시오.


bym
bym 2011년 4월 10일
I think you want N!/(K!*(N-K)!)<--note parentheses
  댓글 수: 1
reem
reem 2011년 4월 10일
Yes I want that,so what is the problem here in my program

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by