1
1
# randomgrowth2.jl
2
- using Winston
2
+ using PyPlot
3
3
using ODE
4
- include (" ../1/gradient.jl" )
5
4
6
5
function randomgrowth2 ()
7
6
num_trials = 2000
8
7
g = 1
9
8
q = 0.7
10
- Ns = 80 # [50, 100, 200]
9
+ Ns = 80
10
+ # Ns = [50, 100, 200]
11
+ clf ()
11
12
# [-1.771086807411 08131947928329]
12
13
# Gap = c d^N
13
14
for jj = 1 : length (Ns)
@@ -23,24 +24,25 @@ function randomgrowth2()
23
24
end
24
25
C = (B - N* om (g,q)) / (sigma_growth (g,q)* N^ (1 / 3 ))
25
26
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 )
31
30
32
31
# # Theory
33
32
t0 = 4
34
33
tn = - 6
35
34
dx = 0.005
36
35
deq = (t, y) -> [y[2 ]; t* y[1 ]+ 2 * y[1 ]^ 3 ; y[4 ]; y[1 ]^ 2 ]
37
36
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
40
39
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 )
44
46
println (mean (C))
45
47
end
46
48
end
@@ -49,7 +51,7 @@ function G(N, M, q)
49
51
# computes matrix G[N,M] for a given q
50
52
GG = floor (log (rand (N,M))/ log (q))
51
53
# float(rand(N,M) < q)
52
-
54
+
53
55
# Compute the edges: the boundary
54
56
for ii = 2 : N
55
57
GG[ii, 1 ] = GG[ii, 1 ] + GG[ii- 1 , 1 ]
@@ -64,7 +66,7 @@ function G(N, M, q)
64
66
# # Plot
65
67
# imagesc((0,N),(M,0),GG)
66
68
# sleep(.01)
67
-
69
+
68
70
return GG[N, M]
69
71
end
70
72
0 commit comments