/************** Approximations to a Wiener Process ************** Author: Mico Loretan loretanm@frb.gov Date: 19 Nov 96 This code is provided without guarantee for public non-commercial use. Approximations to a Wiener process on the [0,1] interval may be accomplished in a number of different ways. By far the easiest method is based on the idea that the Wiener process is the limit of a scaled random walk. Recalling that a random walk is nothing but the cumulative sum of iid increments, we can consider the following code: ****************************************************************/ proc (2)=wiener(n); /* :: Generate an approximation to a Wiener process on the :: [0.1] interval by taking cumulative sum of standard :: normal random numbers. The variable "n" defines the :: fineness of the grid. The returned variables are x, :: the grid from 1/n to 1 at which the function values :: are computed, and y, the values of the (approximate) :: Wiener process. The scaling required is simply :: sqrt(n). */ local x,y,z; x = seqa(1/n,1/n,n); z = rndn(n,1); /* n iid N(0,1) variates */ y = cumsumc(z)/sqrt(n); retp( x,y ); endp; /**************************************************************** The question that remains is how to choose n. This will depend in part on the nature of your application. In most cases, though, setting n=2500 or n=5000 will be more than sufficient. ****************************************************************/