function v=callopt2(u,S0,ex,r,sigma,T)
% value of the integrand for a call option with exercise price ex, r=annual interest 
% rate, sigma=annual vol, S0=current stock price. u=uniform (0,1) input to 
%generate normal variate by inverse transform. T=term
%For Black-Scholes, integrate (0,1).
v=[];
x=S0*exp(norminv(u,r*T-sigma^2*T/2,sigma*sqrt(T)));
%v=exp(-r*T)*max((x-ex),0);
% line above is modified May 13, 2005 so that we can put in a vector of exercise prices
% and so it computes the average.--take out the averaging so stratified
% works!!!!! add line below in place of next three lines.
v=exp(-r*T)*max((x-ex),0);
%for i=1:length(ex)
%    v=[v mean(exp(-r*T)*max((x-ex(i)),0))];
%end