1
1
# Matrices related to stochastic processes
2
2
3
3
import Base: start, next, done
4
- export AiryProcess, BrownianProcess, WhiteNoiseProcess
4
+ export AiryProcess, BrownianProcess, WhiteNoiseProcess, next!
5
5
6
6
abstract StochasticProcess{T<: Real }
7
7
@@ -13,7 +13,7 @@ immutable BrownianProcess{T<:Real} <: StochasticProcess{T}
13
13
dt:: T
14
14
end
15
15
16
- type AiryProcess{S<: Real , T<: Real } <: StochasticProcess{T}
16
+ immutable AiryProcess{S<: Real , T<: Real } <: StochasticProcess{T}
17
17
dt:: T
18
18
beta:: S
19
19
end
41
41
# Airy process #
42
42
# ###############
43
43
start {T} (p:: AiryProcess{T} ) = SymTridiagonal (T[- (2 / p. dt^ 2 )], T[])
44
+
45
+ """
46
+ Like next, but update only the state of the AiryProcess
47
+
48
+ Skip the eigenvalue computation, which gets expensive
49
+ """
50
+ function next! {T} (p:: AiryProcess{T} , S:: SymTridiagonal{T} )
51
+ t = (size (S, 1 )- 1 )* p. dt
52
+
53
+ # Discretized Airy operator plus diagonal noise
54
+ x = inv (p. dt^ 2 )
55
+ push! (S. dv, - 2 x - t + 2 / sqrt (p. dt* p. beta)* randn ())
56
+ push! (S. ev, x)
57
+
58
+ S
59
+ end
44
60
function next {T} (p:: AiryProcess{T} , S:: SymTridiagonal{T} )
45
61
t = (size (S, 1 )- 1 )* p. dt
46
62
47
63
# Discretized Airy operator plus diagonal noise
48
64
x = inv (p. dt^ 2 )
49
- push! (S. dv, - 2 x - t + 2 / sqrt (p. beta / p . dt )* randn ())
65
+ push! (S. dv, - 2 x - t + 2 / sqrt (p. dt * p . beta )* randn ())
50
66
push! (S. ev, x)
51
67
52
- (eigmax (S)* p . dt ^ 2 , S)
68
+ (eigmax (S), S)
53
69
end
54
70
71
+
0 commit comments