/* samplepath.c */ #include #include #include "random.h" #include "normal.h" /* output a one-year sample path for the stochastic differential equation dS/S = sigma dX + mu dt (equation (2.1), "Option Pricing", Wilmott, Dewynne, Howison http://www.oxfordfinancial.co.uk/) break the year into N steps */ int main() { const int N = 250; const double sigma = 0.1, mu = 0.06; double S = 1.0, dS, dX, dt = 1.0/N; int i; usrand (0); printf("%6.3f\n", S); for (i=0; i