function conf = mc ( s0, e, r, sigma, t1, m )

%*****************************************************************************80
%
%% mc() uses Monte Carlo valuation on a European call.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    25 March 2005
%
%  Author:
%
%    Original MATLAB version by Desmond Higham.
%    Modifications by John Burkardt.
%
%  Reference:
%
%    Desmond Higham,
%    Black-Scholes for Scientific Computing Students,
%    Computing in Science and Engineering,
%    November/December 2004, Volume 6, Number 6, pages 72-79.
%
%  Input:
%
%    real S0, the asset price at time 0.
%
%    real E, the exercise price.
%
%    real R, the interest rate.
%
%    real SIGMA, the volatility of the asset.
%
%    real T1, the expiry date.
%
%    integer M, the number of simulations.
%
%  Output:
%
%    real CONF[2], the estimated range of the valuation.
%
% rng ( 'shuffle' );

  svals(1:m,1) = s0 * exp ( ( r - 0.5 * sigma^2 ) * t1 ...
    + sigma * sqrt ( t1 ) * randn ( m, 1 ) );

  pvals(1:m,1) = exp ( - r * t1 ) * max ( svals(1:m,1) - e, 0.0 );

  pmean = mean ( pvals(1:m,1) );

  width = 1.96 * std ( pvals(1:m,1) ) / sqrt ( m );

  conf = [ pmean - width, pmean + width ];

  return
end
