Skip to content

Commit ea060a9

Browse files
committed
Modernize Tracy-Widom code
Now uses new ode23 interface in ODE.jl (c.f. SciML/ODE.jl#61) Removes old demo code
1 parent 5feef50 commit ea060a9

File tree

3 files changed

+9
-44
lines changed

3 files changed

+9
-44
lines changed

demos/book/1/tracywidom.jl

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/densities/TracyWidom.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ function pdf(d::TracyWidom, t::Real)
1414
tt0 && return 0.0
1515
t5 && return 0.0
1616

17-
deq(t, y) = [y[2]; t*y[1]+2y[1]^3; y[4]; y[1]^2]
17+
deq(t, y) = [y[2], t*y[1]+2y[1]^3, y[4], y[1]^2]
1818

19-
y0=[airy(t0); airy(1, t0); 0; airy(t0)^2] # Initial conditions
20-
(ts, y)=ode23(deq, [t0, t], y0) # Solve the ODE
21-
F2=exp(-y[:,3]) # the cumulative distribution
22-
f2=(F2[end]-F2[end-1])/(ts[end]-ts[end-1])# the density at t
19+
a0 = airy(t0)
20+
T = typeof(a0)
21+
y0=T[a0, airy(1, t0), 0, airy(t0)^2] # Initial conditions
22+
(ts, y)=ode23(deq, y0, [t0, t]) # Solve the ODE
23+
ΔF2=exp(-y[end-1][3]) - exp(-y[end][3]) # the cumulative distribution
24+
f2=ΔF2/(ts[end]-ts[end-1]) # the density at t
2325
end
2426
pdf(d::Type{TracyWidom}, t::Real) = pdf(d(), t)
2527

test/densities/TracyWidom.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ if isdefined(:ODE) && isa(ODE, Module)
1010
@test RandomMatrices.pdf(TracyWidom, t) > 0
1111
end
1212

13-
@test rand(TracyWidom, 10) > 0
14-
@test rand(TracyWidom, 100) > 0
13+
@test isfinite(rand(TracyWidom, 10))
14+
@test isfinite(rand(TracyWidom, 100))

0 commit comments

Comments
 (0)