Skip to content

Commit 46e76a7

Browse files
fix examples and docs
1 parent d7f5b24 commit 46e76a7

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

demos/book/8/randomgrowth2.jl

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#randomgrowth2.jl
22
using PyPlot
3-
using ODE
3+
using OrdinaryDiffEq
44

55
function randomgrowth2()
66
num_trials = 2000
@@ -32,16 +32,22 @@ function randomgrowth2()
3232
t0 = 4
3333
tn = -6
3434
dx = 0.005
35-
deq = (t, y) -> [y[2]; t*y[1]+2*y[1]^3; y[4]; y[1]^2]
36-
y0 = [airy(t0); airy(1,t0); 0; airy(t0)^2] # boundary conditions
37-
t, y = ode23(deq, y0, t0:-dx:tn) # solve
38-
F2 = Float64[exp(-y[i][3]) for i = 1:length(y)] # the distribution
39-
f2 = gradient(F2, t) # the density
35+
deq = function (t, y, dy)
36+
dy[1] = y[2]
37+
dy[2] = t*y[1]+2y[1]^3
38+
dy[3] = y[4]
39+
dy[4] = y[1]^2
40+
end
41+
y0 = big.([airy(t0); airy(1,t0); 0; airy(t0)^2]) # boundary conditions
42+
prob = ODEProblem(deq,y0,(t0,tn))
43+
sol = solve(prob,Vern8(), saveat=-dx, abstol=1e-12, reltol=1e-12) # solve
44+
F2 = Float64[exp(-sol[i][3]) for i = 1:length(y)] # the distribution
45+
f2 = gradient(F2, t) # the density
4046

4147
# add(p, Curve(t, f2, "color", "red", "linewidth", 3))
4248
# Winston.display(p)
4349
subplot(1,length(Ns),jj)
44-
plot(t, f2, "r", linewidth = 3)
50+
plot(sol.t, f2, "r", linewidth = 3)
4551
ylim(0, 0.6)
4652
println(mean(C))
4753
end

src/densities/TracyWidom.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ immutable TracyWidom <: ContinuousUnivariateDistribution end
2727
Probability density function of the Tracy-Widom distribution
2828
2929
Computes the Tracy-Widom distribution by directly solving the
30-
Painlevé II equation using the ode23 numerical integrator
30+
Painlevé II equation using the Vern8 numerical integrator
3131
3232
# Arguments
3333
* `d::TracyWidom` or `Type{TracyWidom}`: an instance of `TracyWidom` or the type itself
@@ -49,7 +49,7 @@ pdf(d::Type{TracyWidom}, t::Real) = pdf(d(), t)
4949
Cumulative density function of the Tracy-Widom distribution
5050
5151
Computes the Tracy-Widom distribution by directly solving the
52-
Painlevé II equation using the ode23 numerical integrator
52+
Painlevé II equation using the Vern8 numerical integrator
5353
5454
See `pdf(::TracyWidom)` for a description of the arguments.
5555
"""
@@ -62,7 +62,7 @@ end
6262
cdf(d::Type{TracyWidom}, t::Real) = cdf(d(), t)
6363

6464
# An internal function which sets up the Painleve II differential equation and
65-
# runs it through the ode23 numerical integrator
65+
# runs it through the Vern8 numerical integrator
6666
function _solve_painleve_ii{S<:Real}(t0::S, t::S)
6767
function deq(t, y, dy)
6868
dy[1] = y[2]

0 commit comments

Comments
 (0)