function S = asset_path ( S0, mu, sigma, T, N ) %*****************************************************************************80 % %% ASSET_PATH simulates the behavior of an asset price over time. % % Modified: % % 28 March 2005 % % Author: % % Desmond Higham % % Reference: % % Desmond Higham, % Black-Scholes for Scientific Computing Students, % Computing in Science and Engineering, % November/December 2004, Volume 6, Number 6, pages 72-79. % % Parameters: % % Input, real S0, the asset price at time 0. % % Input, real mu, the expected growth rate. % % Input, real r, the interest rate. % % Input, real sigma, the volatility of the asset. % % Input, real T, the expiry date. % % Input, integer N, the number of steps to take between 0 and T. % % Output, real S(N+1), the option values from time 0 to T in equal steps. % dt = T / N; S = S0 * cumprod ( exp ( ( mu - sigma^2 ) * dt ... + sigma * sqrt ( dt ) * randn ( N, 1 ) ) ); return end