Skip to content

Commit 46cd341

Browse files
committed
Add kernels for stochastic processes
1 parent d0f50f2 commit 46cd341

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/StochasticProcess.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Generates Brownian motion
2+
BrownianProcess(dx::Real, xend::Real) = WhiteNoise(dx, xend)
3+
4+
# Generates a white noise process
5+
function WhiteNoiseProcess(dx::Real, xend::Real)
6+
x=[0:dx:xend]
7+
dW=randn(length(x),1)*sqrt(dx)
8+
end
9+
10+
# Calculates the largest eigenvalue of a stochastic Airy process
11+
# with Brownian noise
12+
function StochasticAiryProcess(dx::Real, xend::Real, beta::Real)
13+
x=[0:dx:xend]
14+
N=length(x)
15+
16+
#Discretized Airy operator
17+
a=-(2/dx^2)*ones(N) - x
18+
b=+(1/dx^2)*ones(N-1)
19+
#Plus noise
20+
dW=WhiteNoiseProcess(dx, xend)
21+
a+=(2/sqrt(beta))*dW/dx
22+
23+
maxeig(SymTridiagonal(a,b))
24+
end
25+
26+
#Sample program
27+
#t=10000 #number of trials
28+
#v=[StochasticAiryProcess(0.001, 10, 2) for i=1:t]
29+
#binsize=.2
30+
#grid=[-5:binsize:2]
31+
#x=hist(v, grid)
32+
#for i=1:length(grid)
33+
# @printf("%10.5f %8d %s\n",grid[i],x[i],repeat("*",int(x[i]/(t*binsize)*200)))
34+
#end
35+

0 commit comments

Comments
 (0)