INTRODUCTION TO Borun D Chowdhury Stochastic Processes

What is a ?

Series of events where a variable takes random values X0, X1….. Xt …

Causality requires Xt depends only on Xt’ where t’

A Markovian process is a memory less stochastic process so that Xt depends only on Xt’

Often it is useful to look at the difference process Yt = Xt - Xt-1 Binomial

The workhorse of stochastic processes is the Binomial Random walk

To understand that we first look at a B(p), a that is 1 with p and 0 with probability q

E[B(p)] = p, V ar[B(p)] = p(1 p) We then define a variable that takes values 1 with probability p and -1 with probability q X =2B(p) 1 i and we have

E[X ]=2p 1,Var[B(p)] = 4p(1 p) i This is a model for a step taken by a drunk Binomial Random Walk

If the drunk takes n steps then we have a new random variable n

Yn = Xi i Its expectation value is X E[Y ]= E[X ]=n(2p 1) n i Its is X

Var(Yn)= Var(Xi)+ Cov(Xi,Xj) i i=j X X6 If the different steps are not correlated (or better yet independent) Var(Y )=4np(1 p) n

Note Yn is also a stochastic process StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19

self.p=p

self.dt=dt self.nsteps=int(self.T/self.dt) Paths.__setup__(self)

self.randoms=2*(np.random.binomial(1,self.p,self.npaths*(self.nsteps-1))-.5) self.randoms.shape=[self.npaths,self.nsteps-1]

for i in range(self.nsteps-1): self.paths[:,i+1]=self.paths[:,i]+self.randoms[:,i]

b_paths=BinaryPaths(11,1,6).get_paths()

number_columns=2 number_rows=3 figsize(12, 9) for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): plt.subplot2grid((number_rows,number_columns),j) plt.plot(b_paths[i],"--o") plt.xlabel("time") Binomial pltRandom.ylabel("position") Walk plt.ylim(-7,7)

From Binomial Walk to Weiner Process but not back! Note that after n steps the scale of fluctuations around the mean The process described above is a Binomial process and happens in discrete times. However for analytical reasons we would like to take a continuum limit of the same. Although having done that, for computational reasons the latter is approximated by a discrete process again. The reason for the analytical expression in continuous time is actually tied to the which for our purposes states that the sum of many independent incrememts by random variables with well defined meanp and variance tends to a (the Gaussian is stable under such sums or, as they are known technically, convolutions).n Thus if we cann pass to a domain where such convergence has happened we do not care about the microscopic model anymore. ⇠ If the above is not clear already, I hope the plots below will help. Here I generate random walks, same as before, for the time interval t = [0, 10) by deviding the interval in 10000 steps. Then we zoom into the central region (any region would do) by factors of 2. You will notice that for the first 5 zoom ins the path looks the same. However, after that the discrete nature of Bernoulli jumps start becoming visible.

In [2]: T=10.0 num_steps_bernoulli=2**12 delta_t_bernoulli=T/num_steps_bernoulli

https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 2 of 6 StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19

self.p=p

self.dt=dt self.nsteps=int(self.T/self.dt) Paths.__setup__(self)

self.randoms=2*(np.random.binomial(1,self.p,self.npaths*(self.nsteps-1))-.5) self.randoms.shape=[self.npaths,self.nsteps-1]

for i in range(self.nsteps-1): self.paths[:,i+1]=self.paths[:,i]+self.randoms[:,i]

b_paths=BinaryPaths(11,1,6).get_paths()

number_columns=2 number_rows=3 figsize(12, 9) for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): plt.subplot2grid((number_rows,number_columns),j) plt.plot(b_paths[i],"--o") plt.xlabel("time") Binomial Random Walk plt.ylabel("position") plt.ylim(-7,7)

Covariance of random walk

Covariance of steps Cov(X ,X )=4p(1 p) n m n,m

From Binomial Walk to Weiner Process but not back!

The process described above is a Binomial process and happens in discrete times. However for analytical reasons we would like to take a Covariance of paths continuum limit of the same. Although having done that, for computational reasons the latter is approximated by a discrete process again. The reason for the analytical expression in continuous time is actually tied to the central limit theorem which for our purposes states that the sum of many independent incrememts by random variables with well defined mean and variance tends to a Gaussian process (the Gaussian is stable under such sums or, as they are known technically, convolutions). Thus if we can pass to a domain where such convergence has happened we do not care about the microscopic model anymore.

If the above is not clear already, I hope the plots below will help. Here I generate random walks, same as before, for the time interval t = [0, 10) Cov(Yn,Ym)=4min(n, m)p(1by deviding the interval pin 10000) steps. Then we zoom into the central region (any region would do) by factors of 2. You will notice that for the first 5 zoom ins the path looks the same. However, after that the discrete nature of Bernoulli jumps start becoming visible. In [2]: T=10.0 num_steps_bernoulli=2**12 delta_t_bernoulli=T/num_steps_bernoulli

https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 2 of 6 StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19

b=BinaryPaths(10,delta_t_bernoulli,1) time_line=b.get_timeline() path=b[0]

number_columns=2 number_rows=4 figsize(12, 9)

StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses# plot the entire path first and then regions zoomed02/06/16 in by 14factor:19 of 2s for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): plt.subplot2grid((number_rows,number_columns),j) b=BinaryPaths(10,delta_t_bernoulli,1) time_line_for_plot=time_line[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_b time_line=b.get_timeline() ernoulli/2 +num_steps_bernoulli/(2**(i+1))] path=b[0] path_for_plot=path[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_bernoulli/2 +num_steps_bernoulli/(2**(i+1))] number_columns=2 number_rows=4 plt.plot(time_line_for_plot,path_for_plot) figsize(12, 9) plt.xlabel("time") A glimpse of the central limit theorem plt.ylabel("position") # plot the entire path first and then regions zoomed in by factor of 2s for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): For a very plt.subplot2grid large number((number_rows of steps,number_columns),j) time_line_for_plot=time_line[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_b ernoulli/2 +num_steps_bernoulli/(2**(i+1))] path_for_plot=path[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_bernoulli/2 +num_steps_bernoulli/(2**(i+1))]

plt.plot(time_line_for_plot,path_for_plot) plt.xlabel("time") plt.ylabel("position")

Take the central half and zoom in

The distribution looks the same (after rescaling)

It is intructive to understand what is happening here clearly. The discussion below works for all values of p away from 0 and 1 for sufficiently large n.

The change in position after n steps is given by Yn = 2Binomial(n, p) − n . For large enough n (depending on how important tail events are the cutoffs are different) this can be approximated by Yn ∼ 2(np, √‾n‾p‾(‾1‾‾−‾‾p‾)) − n = n(2p − 1) + 2√‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) = n(2p − 1) + √4‾‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) Specializing to p = .5, if we progressively look at an interval n we can approximate 2k It is intructive to understand what is happening here clearly. The discussion below works for all values of p away from and for sufficiently‾‾n‾ large 0 1Yn ∼ (0, 1) . k n √ 2 and the plot is qualitatively the same as long as k is not large enough to violate the Binomial to Gaussian approximation. In the plots above we The change in position after n steps is given by have the size of intervals Yn = 2Binomial(n, p) − n . For large enough n (depending on how important tail events are theIn cuto [7]:ffs areprint different) [num_steps_bernoulli this can be approximated/2** byk for k in range(9)] Yn ∼ 2(np, √‾n‾p‾[4096,(‾1‾‾−‾‾p‾) )2048,− n 1024, 512, 256, 128, 64, 32, 16] = n(2p − 1) + 2√‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) = n(2p − 1) + 4‾‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb√ Page 3 of 6 Specializing to p = .5, if we progressively look at an interval n we can approximate 2k ‾‾n‾ Yn ∼ (0, 1) √ 2k and the plot is qualitatively the same as long as k is not large enough to violate the Binomial to Gaussian approximation. In the plots above we have the size of intervals

In [7]: print [num_steps_bernoulli/2**k for k in range(9)]

[4096, 2048, 1024, 512, 256, 128, 64, 32, 16]

https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 3 of 6 StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19

b=BinaryPaths(10,delta_t_bernoulli,1) time_line=b.get_timeline() path=b[0]

number_columns=2 number_rows=4 figsize(12, 9)

# plot the entire path first and then regions zoomed in by factor of 2s for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): plt.subplot2grid((number_rows,number_columns),j) time_line_for_plot=time_line[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_b ernoulli/2 +num_steps_bernoulli/(2**(i+1))] path_for_plot=path[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_bernoulli/2 +num_steps_bernoulli/(2**(i+1))]

plt.plot(time_line_for_plot,path_for_plot) A glimpse pltof.xlabel the("time" central) limit theorem plt.ylabel("position")

It is intructive to understand what is happening here clearly. The discussion below works for all values of p away from 0 and 1 for sufficiently large n. HoweverThe change zooming in position after n stepsin toois given bymuch reveals the Bernoulli “microstructure” Yn = 2Binomial(n, p) − n . For large enough n (depending on how important tail events are the cutoffs are different) this can be approximated by Yn ∼ 2(np, √‾n‾p‾(‾1‾‾−‾‾p‾)) − n = n(2p − 1) + 2√‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) = n(2p − 1) + √4‾‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) Specializing to p = .5, if we progressively look at an interval n we can approximate 2k ‾‾n‾ Yn ∼ (0, 1) √ 2k and the plot is qualitatively the same as long as k is not large enough to violate the Binomial to Gaussian approximation. In the plots above we have the size of intervals

In [7]: print [num_steps_bernoulli/2**k for k in range(9)] [4096, 2048, 1024, 512, 256, 128, 64, 32, 16]

https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 3 of 6 StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19

b=BinaryPaths(10,delta_t_bernoulli,1) time_line=b.get_timeline() path=b[0]

number_columns=2 number_rows=4 figsize(12, 9)

# plot the entire path first and then regions zoomed in by factor of 2s for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): plt.subplot2grid((number_rows,number_columns),j) time_line_for_plot=time_line[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_b ernoulli/2 +num_steps_bernoulli/(2**(i+1))] path_for_plot=path[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_bernoulli/2 +num_steps_bernoulli/(2**(i+1))]

A glimpse of the central limit theorem plt.plot(time_line_for_plot,path_for_plot) plt.xlabel("time") plt.ylabel("position")

What we are doing is the opposite of renormalisation group transformation

If we perform the RG operation of “coarse-graining”, i.e. if we start with the Bernoulli and

It is intructive to understand what is happening here clearly. The discussion below works for all values of p away from 0 and 1 for sufficiently large n. The change in position after n steps is given by Yn = 2Binomial(n, p) − n . 1. Zoom out For large enough n (depending on how important tail events are the cutoffs are different) this can be approximated by Yn ∼ 2(np, √‾n‾p‾(‾1‾‾−‾‾p‾)) − n = n(2p − 1) + 2√‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) 2. Rescale back = n(2p − 1) + √4‾‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) Specializing to p = .5, if we progressively look at an interval n we can approximate 2k ‾‾n‾ 3. Repeat Yn ∼ (0, 1) √ 2k and the plot is qualitatively the same as long as k is not large enough to violate the Binomial to Gaussian approximation. In the plots above we have the size of intervals

In [7]: print [num_steps_bernoulli/2**k for k in range(9)] We will converge to a stable distribution: The[4096, normal2048, 1024, 512, 256, distribution128, 64, 32, 16]

https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 3 of 6 In fact this will happen independent of the microscopic distribution as long as it has a well defined mean and variance StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19

b=BinaryPaths(10,delta_t_bernoulli,1) time_line=b.get_timeline() path=b[0] number_columns=2 number_rows=4 figsize(12, 9)

# plot the entire path first and then regions zoomed in by factor of 2s for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): plt.subplot2grid((number_rows,number_columns),j) time_line_for_plot=time_line[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_b ernoulli/2 +num_steps_bernoulli/(2**(i+1))] path_for_plot=path[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_bernoulli/2 +num_steps_bernoulli/(2**(i+1))]

StochasticProcesses/RandomWalkAndWeinerProcess.ipynb plt.plot(time_line_for_plot,path_for_plot at master · borundev/StochasticProcesses) 02/06/16 14:19 plt.xlabel("time") plt.ylabel("position") b=BinaryPaths(10,delta_t_bernoulli,1) time_line=b.get_timeline() path=b[0]

number_columns=2 number_rows=4 figsize(12, 9)

# plot the entire path first and then regions zoomed in by factor of 2s for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): plt.subplot2grid((number_rows,number_columns),j) time_line_for_plot=time_line[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_b ernoulli/2 +num_steps_bernoulli/(2**(i+1))] path_for_plot=path[num_steps_bernoulli/2 -num_steps_bernoulli/(2**(i+1)):num_steps_bernoulli/2 +num_steps_bernoulli/(2**(i+1))]

plt.plot(time_line_for_plot,path_for_plot) plt.xlabel("time") plt.ylabel("position")

It is intructive to understand what is happening here clearly. The discussion below works for all values of p away from 0 and 1 for sufficiently large n. A glimpse of the central limit theorem It is intructive to understand what is happening here clearly. The discussion below works for all values of p away from 0 and 1 for sufficiently large The change in positionn. after n steps is given by Bernoulli random walk The change in position after n steps is given by Yn = 2Binomial(n, p) − n . For large enough n (depending on how important tail events Yaren = the2Bin cutoomial(ffns, p are) − n di . fferent) this can be approximated by For large enough n (depending on how important tail events are the cutoffs are different) this can be approximated by Large n limit Yn Y∼n ∼ 22(n(pn, √p‾n,‾p√‾(‾1‾‾n−‾‾p‾p‾‾)()‾1−‾‾−n‾‾p‾)) − n = n(2p − 1) + 2 ‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) = n(2p − 1) +√ 2√‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) = n(2p − 1) + √4‾‾n‾p‾(‾1‾‾−‾‾p‾)(0, 1) n np  Specializing to p = .5, if we progressively look at an interval= ( 2 we− can1) approximate+ √4‾‾n‾p‾(‾1‾‾−‾‾p‾) (0, 1) StochasticProcesses/RandomWalkAndWeinerProcess.ipynb2k at master · borundev/StochasticProcesses 02/06/16 14:19 n ‾‾n‾ Specializing to , if weSuppose progressively the microscopic look at time an scaleinterval is much StochasticProcesses/RandomWalkAndWeinerProcess.ipynbY nwe shorter∼ can  approximatethan(0, 1 times) of at master · borundev/StochasticProcesses 02/06/16 14:19 p = .5 k interest 2k √ 2 andand the aroundplot is qualitatively n=256 we thestart same seeing as long differences. as k is not large enough to violate the Binomial to Gaussian approximation. In the plots above we have the size of intervals ‾‾n‾ t dt Ynand∼ around n=256 we(0 start, 1) seeing differences. This shows us something interesting. Let us assume that each√ stepk takes time δt and we are interested in studying processes over time dt ≫ δt print [num_steps_bernoulli/2⌧**k for k in range(92)] and the plot is qualitativelyInwe [7]: have the same as long as k is not large enoughThis shows to us violatesomething the interesting. Binomial Let us toassume Gaussian that each approximation. step takes time δt and In we the are interestedplots above in studying we processes over time dt ≫ δt Then we can write the above as we have have the size of intervals [4096, 2048, 1024, 512, 256, 128, 64, 32, d16]Y(t) = μdt + σ√‾d‾t(0, 1) dY(t) = μdt + σ√‾d‾t(0, 1) where μ 2p−1 and σ ‾4‾p(‾1‾−‾p‾) . = δt = √ 2p−1 4p(1−p) In [7]: printhttps://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb [num_steps_bernoulliδt /2**k for k inwhere range μ = ( 9and)] σ = ‾‾‾‾‾‾. Page 3 of 6 δt √ δt Take great care to see that there is a square root on here. This makes the left hand side very different from ordinary calculus differential Takedt great care to see that there is a square root on here. This makes the left hand side very different from ordinary calculus differential [4096, 2048,elements. For1024, instance 512, while the256, limit 128, 64, 32, 16] dt elements. For instance while the limit lim dY(t) dt→0 lim dY(t) dt→0 is well defined and goes to zero, the velocity is well defined and goes to zero, the velocity dY(t) dY(t) https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynblim lim Page 3 of 6 dt→0 dt dt→0 dt is not defined. This signifies that this kind of curve is everywhereis not defined. non-di Thisfferentiable. signifies that this kind of curve is everywhere non-differentiable.

It would be useful to keep in mind that all this discussionIt would is happening be useful towhen keep d int → mind0 comparedthat all this todiscussion other large is happening time scales when in thedt → problem0 compared while to other large time scales in the problem while maintaining dt ≫ δt so as to be able to justify the Binomialmaintaining to Normal dt ≫ approximationδt so as to be above.able to justify the Binomial to Normal approximation above.

The Weiner process is this approximated process takenThe at Weiner all scales. process In is other this approximated words one forgets process that taken oen at firstall scales. zoomed In outother and words thus one infinite forgets that oen first zoomed out and thus infinite zooming in is possible. This is related to the central limit theorem in that we first take the limit of addining ifinite, independent random variable and zooming in is possible. This is related to the central limit theorem in that we first take the limit of addining ifinite, independent random variable and get a and then subdivide the normal as many times as we like without recovering the original distribution. get a normal distribution and then subdivide the normal as many times as we like without recovering the original distribution. Formally the Weiner process is defined as Formally the Weiner process is defined as dWt = √‾d‾t(0, 1) and thusd toW matcht = √ our‾d‾t previous(0, 1) example we have dY = μdt + σdW. and thus to match our previous example we have dY = μdt + σdW. dW should be interpreted as a random draw from a unit normal multiplied by √‾d‾t . Thus it is immediately clear that dW 2 is drawn from a χ2 dW should be interpreted as a random draw from a unitdistribution normal ofmultiplied one degree by of√ ‾d freedom‾t . Thus withit is meanimmediately dt and standardclear that deviation dW 2 is √drawn‾2dt. There from isa hardlyχ2 a book on stochastic calculus that will not distribution of one degree of freedom with mean dt andmention standard dW 2 deviation= dt. We can√‾2 understanddt. There isit the hardly following a book way. on If we stochastic have calculus that will not mention dW 2 = dt. We can understand it the following way. If we have N Q W 2 N = ∑ Δ i 2 i=1 with time splitQ as= ΔW then is a 2 distribution with mean and variance 2 and in the limit the value of . Δ∑t = T/Ni Q χN NΔT = T 2NΔT N → ∞ Q → T It is in this sense, udneri=1 the integral/summation, that 2 even though there is no convergence for any one interval. This is again a result of with time split as then is a 2 distribution with mean and variance 2 andd inW the= limitdt the value of . Δt = T/N Q χN the central limitNΔ theorem.T = T In particular we2 NhaveΔT the often used resultsN → ∞ Q → T It is in this sense, udner the integral/summation, that d 2 dt even though there is no convergence for any one interval. This is again a result of W = dW the central limit theorem. In particular we have the often used results ⟨ t ⟩ = 0 and ⟨dWt ⟩ = 0 2 dWt = dt and However note that2 if the intervals are independent dWt = dt ⟨dWt dWt′ ⟩ = dt ∗ cov((0, 1), (0, 1)) = 0 However note that if the intervals are independent We can integrate the Weiner process to get ⟨dWt dWt′ ⟩ = dt ∗ cov((0, 1), (0, 1)) = 0 t Wt = dWt = √t(0, 1) We can integrate the Weiner process to get ∫0 giving t Wt = dWt = √t(0, 1) ⟨Wt ⟩ = 0 ∫0 giving var(Wt ) = t Covariance of and ⟨WWt ⟩ =Wt0′ The way the vabovear(W ist ) written= t can lead to an erroneous idea (that can seep into code) that and are independet and thus have covariance 0. Wt Wt′ Covariance of and However, the path from 0 to min(t, t′) is the same so they are not independent. For concreteness take t′ > t then what we really have is Wt Wt′ ′ Wt = t (0, 1)W ′ t = √t‾‾‾‾t‾ (0, 1) The way the above is written can lead to an erroneous idea (that can seep into code) that and are independet√ 1 andt thus− have −covariance2 0. W W ′ where the two subscripts on the normal tdenote independentt draws and However, the path from 0 to min(t, t′) is the same so they are not independent. For concreteness take t′ > t then what we really have is Wt′ = Wt + Wt−t′ ′ Wt = t1(0, 1)Wt′ −t = √t‾‾−‾‾t‾2(0, 1) giving√ where the two subscripts on the normal denote independent draws and ′ cov(Wt , Wt′ ) = t cov(1(0, 1), 1(0, 1)) + √t√‾t ‾‾−‾‾t cov(1(0, 1), 2(0, 1)) Wt′ = Wt + Wt−t′ = t giving In general ′ ′ cov(W , W ′ ) = min(t, t ) cov(Wt , Wt′ ) = t cov(1(0, 1), 1(0, 1)) + √t√‾t ‾‾−‾‾t cov(1(0, 1), 2(0, 1)) t t = We can now simulate paths usingt the Weiner process and zoom in to see the difference from the Bernoulli process. In general In [3]: class WeinerPaths′ (Paths): cov(Wt , W t′ ) = min(t, t ) We can now simulate paths using the Weiner process and zoom in to see the difference from the Bernoulli process. https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 4 of 6

In [3]: class WeinerPaths(Paths):

https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 4 of 6 StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19 and around n=256 we start seeing differences.

This shows us something interesting. Let us assume that each step takes time δt and we are interested in studying processes over time dt ≫ δt we have dY(t) = μdt + σ√‾d‾t(0, 1) p where μ = 2 −1 and σ = ‾4‾p(‾1‾−‾p‾) . δt √ δt Take great care to see that there is a square root on dt here. This makes the left hand side very different from ordinary calculus differential elements. For instance while the limit lim dY(t) dt→0 is well defined and goes to zero, the velocity dY(t) lim dt→0 dt is not defined. This signifies that this kind of curve is everywhere non-differentiable. StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19

def __init__(self,T,nsteps,npaths,mu=0,sigma=1): super(WeinerPaths,self).__init__(T,npaths) It would be useful to keep in mind that all this discussion is happening when dt compared to other large time scales in the problem while self.nsteps→=nsteps0 self.dt=1.0*self.T/self.nsteps maintaining so as to be able to justify the Binomial to Normal approximation Paths.__setup__( selfabove.) dt ≫ δt self.mu=mu self.sigma=sigma self.dW=np.sqrt(self.dt) self.randoms=np.random.normal(0,1,npaths*(nsteps-1)) The Weiner process is this approximated process taken at all scales. In other self.randoms words.shape=[npaths , onensteps-1] forgets that oen first zoomed out and thus infinite zooming in is possible. This is related to the central limit theorem in that we first for i takein range(nsteps the-1): limit of addining ifinite, independent random variable and self.paths[:,i+1]=self.paths[:,i]+self.mu*self.dt+self.sigma*self.dW*self.randoms[:,i] get a normal distribution and thenA subdivide Wiener theprocess normal is asthe many limit times of a asprocess we like that without happens recovering in time the dt original and is distribution. num_steps_weiner=num_steps_bernoulli*2**6 distributed normally with variance dt sigma=1/np.sqrt(delta_t_bernoulli) # generate one path with time interval 10 devided into 10000 steps w=WeinerPaths(10,num_steps_weiner,1,sigma=sigma) Formally the Weiner process is defined as time_line=w.get_timeline() path=w[0]

number_columns =2 dWt = √‾d‾tnumber_rows(0=4 , 1) figsize(12, 9) and thus to match our previous example we have dY μdt σdW. # plot the entire path first and then regions zoomed in by factor of 2s = + for i,j in enumerate([(i/number_columns,i%number_columns) for i in range(number_columns*number_row s)]): plt.subplot2grid((number_rows,number_columns),j) time_line_for_plot=time_line[num_steps_weiner/2 -num_steps_weiner/(2**(i+1)):num_steps_weiner/ 2 +num_steps_weiner/(2**(i+1))] should be interpreted as a random draw from a unit normal multiplied path_for_plot by =path[num_steps_weiner. Thus/ 2 it-num_steps_weiner is immediately/(2**(i+1)):num_steps_weiner clear/2 +num_ste that 2 is drawn from a 2 dW ps_weiner/(2**(√i+1))]‾d‾t dW χ We can simulate this process and repeat the zooming in process plt.plot(time_line_for_plot,path_for_plot) distribution of one degree of freedom with mean and standard deviation plt. xlabel("time") . There is hardly a book on stochastic calculus that will not dt plt.ylabel√(‾2"position"dt ) mention dW 2 = dt. We can understand it the following way. If we have N Q W 2 = ∑ Δ i i=1 with time split as then is a 2 distribution with mean and variance 2 and in the limit the value of . Δt = T/N QThis isχ Na simulation based on NΔT = T 2NΔT N → ∞ Q → T It is in this sense, udner the integral/summation,finite steps so that still d Whas2 = dt even though there is no convergence for any one interval. This is again a result of the central limit theorem. In particularmicrostructure we have the often but theused results theoretical Wiener process is ⟨dWt ⟩ = 0 scale independent. and https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 5 of 6 2 dWt = dt However note that if the intervals are independent

⟨dWt dWt′ ⟩ = dt ∗ cov((0, 1), (0, 1)) = 0 We can integrate the Weiner process to get t Wt = dWt = √t(0, 1) ∫0 giving

⟨Wt ⟩ = 0 var(Wt ) = t Covariance of and Wt Wt′ The way the above is written can lead to an erroneous idea (that can seep into code) that and are independet and thus have covariance 0. Wt Wt′ However, the path from 0 to min(t, t′) is the same so they are not independent. For concreteness take t′ > t then what we really have is ′ Wt = √t1(0, 1)Wt′ −t = √t‾‾−‾‾t‾2(0, 1) where the two subscripts on the normal denote independent draws and

Wt′ = Wt + Wt−t′ giving

′ cov(Wt , Wt′ ) = t cov(1(0, 1), 1(0, 1)) + √t√‾t ‾‾−‾‾t cov(1(0, 1), 2(0, 1)) = t In general ′ cov(Wt , Wt′ ) = min(t, t ) We can now simulate paths using the Weiner process and zoom in to see the difference from the Bernoulli process.

In [3]: class WeinerPaths(Paths):

https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 4 of 6 StochasticProcesses/RandomWalkAndWeinerProcess.ipynb at master · borundev/StochasticProcesses 02/06/16 14:19 and around n=256 we start seeingStochastic differences. Calculus

This shows us something interesting.Above Let we us naturally assume that came each across step takes time δt and we are interested in studying processes over time dt ≫ δt we have dY(t) = μdt + σ√‾d‾t(0, 1) p where μ = 2 −1 and σ = ‾4‾p(‾1‾−‾p‾) . δt √ δtAnd by construction we know how to solve it Take great care to see that there is a square root on dt here. This makes the left hand side very different from ordinary calculus differential elements. For instance while theIn limit general we can have lim dY(t) dt→0 is well defined and goes to zero, the velocity dS(t)=a(t, Wt)dt + b(t, Wt)dWt dY(t) lim and this will involve solving dt→0 dt is not defined. This signifies that this kind of curve is everywhere non-differentiable.

It would be useful to keep in mind that all this discussion is happeningG(t) dWwhent dt → 0 compared to other large time scales in the problem while maintaining dt ≫ δt so as to be able to justify the Binomial toZ Normal approximation above. The Weiner process is this approximatedWe will discuss process properties taken at allof scales.dW and In how other to words tackle one stochastic forgets that calculus oen first zoomed out and thus infinite zooming in is possible. This is relatednext time to the central limit theorem in that we first take the limit of addining ifinite, independent random variable and get a normal distribution and then subdivide the normal as many times as we like without recovering the original distribution.

Formally the Weiner process is defined as dWt = √‾d‾t(0, 1) and thus to match our previous example we have dY = μdt + σdW. dW should be interpreted as a random draw from a unit normal multiplied by √‾d‾t . Thus it is immediately clear that dW 2 is drawn from a χ2 distribution of one degree of freedom with mean dt and standard deviation √‾2dt. There is hardly a book on stochastic calculus that will not mention dW 2 = dt. We can understand it the following way. If we have N Q W 2 = ∑ Δ i i=1 with time split as then is a 2 distribution with mean and variance 2 and in the limit the value of . Δt = T/N Q χN NΔT = T 2NΔT N → ∞ Q → T It is in this sense, udner the integral/summation, that dW 2 = dt even though there is no convergence for any one interval. This is again a result of the central limit theorem. In particular we have the often used results

⟨dWt ⟩ = 0 and 2 dWt = dt However note that if the intervals are independent

⟨dWt dWt′ ⟩ = dt ∗ cov((0, 1), (0, 1)) = 0 We can integrate the Weiner process to get t Wt = dWt = √t(0, 1) ∫0 giving

⟨Wt ⟩ = 0 var(Wt ) = t Covariance of and Wt Wt′ The way the above is written can lead to an erroneous idea (that can seep into code) that and are independet and thus have covariance 0. Wt Wt′ However, the path from 0 to min(t, t′) is the same so they are not independent. For concreteness take t′ > t then what we really have is ′ Wt = √t1(0, 1)Wt′ −t = √t‾‾−‾‾t‾2(0, 1) where the two subscripts on the normal denote independent draws and

Wt′ = Wt + Wt−t′ giving

′ cov(Wt , Wt′ ) = t cov(1(0, 1), 1(0, 1)) + √t√‾t ‾‾−‾‾t cov(1(0, 1), 2(0, 1)) = t In general ′ cov(Wt , Wt′ ) = min(t, t ) We can now simulate paths using the Weiner process and zoom in to see the difference from the Bernoulli process.

In [3]: class WeinerPaths(Paths):

https://github.com/borundev/StochasticProcesses/blob/master/RandomWalkAndWeinerProcess.ipynb Page 4 of 6