Computing an Expectation in Matlab

I'm trying to compute the sum of x*binopdf(x,18,.96) for values of x from 0 to 16. How can I do that? It keeps giving me errors.

답변 (1개)

Roger Stafford
Roger Stafford 2017년 2월 25일

0 개 추천

The code
x = 0:16;
E = sum(x.*binopdf(x,18,.96));
should give you the answer.

댓글 수: 3

Shane Kosir
Shane Kosir 2017년 2월 25일
didn't work
Roger Stafford
Roger Stafford 2017년 2월 25일
편집: Roger Stafford 2017년 2월 25일
Is there some reason why your x ranges only over 0:16 and yet your N value in binopdf is equal to 18? As it stands, it will not give you the true expected value.
Also please tell me in what respect it "didn't work".
Walter Roberson
Walter Roberson 2017년 2월 25일
When I use the above code, the value I get is _exactly the same as I get when I compute the precise value 36848322448959471846167088 / 14551915228366851806640625 through a different software package.

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

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

질문:

2017년 2월 25일

편집:

2017년 2월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by