11# randomgrowth2.jl
2- using Winston
2+ using PyPlot
33using ODE
4- include (" ../1/gradient.jl" )
54
65function randomgrowth2 ()
76 num_trials = 2000
87 g = 1
98 q = 0.7
10- Ns = 80 # [50, 100, 200]
9+ Ns = 80
10+ # Ns = [50, 100, 200]
11+ clf ()
1112 # [-1.771086807411 08131947928329]
1213 # Gap = c d^N
1314 for jj = 1 : length (Ns)
@@ -23,24 +24,25 @@ function randomgrowth2()
2324 end
2425 C = (B - N* om (g,q)) / (sigma_growth (g,q)* N^ (1 / 3 ))
2526 d = 0.2
26- x, n = hist (C - exp (- N* 0.0025 - 3 ), - 6 : d: 4 )
27- p = FramedPlot ()
28- h = Histogram (n/ (d* num_trials), step (x))
29- h. x0 = first (x)
30- add (p, h)
27+ subplot (1 ,length (Ns),jj)
28+ plt. hist (C - exp (- N* 0.0025 - 3 ), normed = true )
29+ xlim (- 6 , 4 )
3130
3231 # # Theory
3332 t0 = 4
3433 tn = - 6
3534 dx = 0.005
3635 deq = (t, y) -> [y[2 ]; t* y[1 ]+ 2 * y[1 ]^ 3 ; y[4 ]; y[1 ]^ 2 ]
3736 y0 = [airy (t0); airy (1 ,t0); 0 ; airy (t0)^ 2 ] # boundary conditions
38- t, y = ode23 (deq, t0: - dx: tn, y0 ) # solve
39- F2 = exp (- y[:, 3 ]) # the distribution
37+ t, y = ode23 (deq, y0, t0: - dx: tn) # solve
38+ F2 = Float64[ exp (- y[i][ 3 ]) for i = 1 : length (y)] # the distribution
4039 f2 = gradient (F2, t) # the density
41-
42- add (p, Curve (t, f2, " color" , " red" , " linewidth" , 3 ))
43- Winston. display (p)
40+
41+ # add(p, Curve(t, f2, "color", "red", "linewidth", 3))
42+ # Winston.display(p)
43+ subplot (1 ,length (Ns),jj)
44+ plot (t, f2, " r" , linewidth = 3 )
45+ ylim (0 , 0.6 )
4446 println (mean (C))
4547 end
4648end
@@ -49,7 +51,7 @@ function G(N, M, q)
4951 # computes matrix G[N,M] for a given q
5052 GG = floor (log (rand (N,M))/ log (q))
5153 # float(rand(N,M) < q)
52-
54+
5355 # Compute the edges: the boundary
5456 for ii = 2 : N
5557 GG[ii, 1 ] = GG[ii, 1 ] + GG[ii- 1 , 1 ]
@@ -64,7 +66,7 @@ function G(N, M, q)
6466 # # Plot
6567 # imagesc((0,N),(M,0),GG)
6668 # sleep(.01)
67-
69+
6870 return GG[N, M]
6971end
7072
0 commit comments