Computing the expected value of a function of a binomially distributed r.v

551 Views Asked by At

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
0

There are 0 best solutions below