Computing an Expectation in Matlab
10 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Roger Stafford
2017-2-25
The code
x = 0:16;
E = sum(x.*binopdf(x,18,.96));
should give you the answer.
3 个评论
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
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Performance and Memory 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!