1

I'm trying to compute the expected value of a function of X, where X is binomially distributed. So I want to compute something on the form of sum(Pr(X=k)*f(k),k=0,..,n). Now I want to see if the value converges as the binomial tree increases, i.e. if n increases. However, for increasing n, the (n over k) term in Pr(X=k) goes to infinity for some k, whereas the function f(k)=0, this gives a multiplication of Inf*0 which produces NaN in matlab. Hence the result is NaN.

However, by computing the analogous problem in matrix form, I know the expected value should converge.

So my question is, how can I deal with this?

This is the code I've got so far (for some parameters, u~d~0.5. K=s=100)

sum=0;
for k=0:N;
    tmp=exp(-r*T)*nchoosek(N,k)*q_u^k*(1-q_u)^(N-k)*max(s*u^k*d^(N-k)-K,0);
    sum=sum+tmp;
end
Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102
Good Guy Mike
  • 187
  • 1
  • 6
  • 1
    You may have numerical precission issues from computing `nchoosek(N,k)` (very large) and multiplying by `q_u^k` (very small). Use [`binopdf`](http://www.mathworks.es/es/help/stats/binopdf.html) instead – Luis Mendo Feb 01 '14 at 17:23

0 Answers0