
	
function [v,x,CALL]=calloptloggam(y,S0,ex,r,sigma,T)
	
% value for a call option with exercise price ex, r=annual interest
% input y=vector of gamma(2,1) variates 
% rate, sigma=annual vol, S0=current stock price. n=number of simulations generate gamma variate. T=maturity
% to compare with Black-Scholes price, integrate over (0,1) or simulate using
%y=gamrnd(2,1,1,n;        calloptloggam(y,S0,ex,r,sigma,T);
b=sigma*sqrt(T)/.8031;   a=-log(gamma(2+b));         %  
x=S0*exp(a)*y.^b;    % stock price at time T
v=exp(-r*T)*max((x-ex),0);           %  This is the discounted to present value of the call option
[CALL,PUT] = BLSPRICE(S0,ex,r,T,sigma,0);   % this is the corresponding Black-Scholes Price
v=mean(v);