Skip to content

Commit

Permalink
fix length n |-> n+1
Browse files Browse the repository at this point in the history
  • Loading branch information
rmsrosa committed Jul 2, 2023
1 parent fb37705 commit fa56f24
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/literate/examples/01-wiener_linearhomogeneous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ info = (

# The *target* solution as described above is implemented as

function target_solver!(xt::Vector{T}, t0::T, tf::T, x0::T, f::F, yt::Vector{T}, rng::AbstractRNG) where {T, F}
target_solver! = function (xt::Vector{T}, t0::T, tf::T, x0::T, f::F, yt::Vector{T}, rng::AbstractRNG) where {T, F}
axes(xt) == axes(yt) || throw(
DimensionMismatch("The vectors `xt` and `yt` must match indices")
)
Expand Down
2 changes: 1 addition & 1 deletion docs/literate/examples/10-risk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ nothing # hide

# The actual surplus is $U_t = X_t - O_t - C_t$, so we may visualize a sample solution of the surplus by subtracting these two noises from the solution of the above RODE.

plt_surplus = plot(range(t0, tf, length=ntgt), suite.xt .- suite.yt[:, 1] .- suite.yt[:, 3], xaxis="\$t\$", yaxis="\$u\$", label="\$U_t\$", linecolor=1)
plt_surplus = plot(range(t0, tf, length=ntgt+1), suite.xt .- suite.yt[:, 1] .- suite.yt[:, 3], xaxis="\$t\$", yaxis="\$u\$", label="\$U_t\$", linecolor=1)

#

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/01-wiener_linearhomogeneous.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ info = (
The *target* solution as described above is implemented as

````@example 01-wiener_linearhomogeneous
function target_solver!(xt::Vector{T}, t0::T, tf::T, x0::T, f::F, yt::Vector{T}, rng::AbstractRNG) where {T, F}
target_solver! = function (xt::Vector{T}, t0::T, tf::T, x0::T, f::F, yt::Vector{T}, rng::AbstractRNG) where {T, F}
axes(xt) == axes(yt) || throw(
DimensionMismatch("The vectors `xt` and `yt` must match indices")
)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/10-risk.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ nothing # hide
The actual surplus is $U_t = X_t - O_t - C_t$, so we may visualize a sample solution of the surplus by subtracting these two noises from the solution of the above RODE.

````@example 10-risk
plt_surplus = plot(range(t0, tf, length=ntgt), suite.xt .- suite.yt[:, 1] .- suite.yt[:, 3], xaxis="\$t\$", yaxis="\$u\$", label="\$U_t\$", linecolor=1)
plt_surplus = plot(range(t0, tf, length=ntgt+1), suite.xt .- suite.yt[:, 1] .- suite.yt[:, 3], xaxis="\$t\$", yaxis="\$u\$", label="\$U_t\$", linecolor=1)
````

````@example 10-risk
Expand Down
10 changes: 5 additions & 5 deletions docs/src/noises/colored.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ y0 = 0.0
t0 = 0.0
tf = 2.0
n = 2^10
tt = range(t0, tf, length=n)
dt = (tf - t0) / (n - 1)
tt = range(t0, tf, length=n+1)
dt = (tf - t0) / n
nothing # hide
```

Expand All @@ -72,7 +72,7 @@ ou_noises = (OrnsteinUhlenbeckProcess(t0, tf, y0, 1/τ, √(2/τ)) for τ in τs
nothing # hide
```

This `noises` is a `Tuple` where each element is an OU sampler. With each sampler `noises[i]`, we draw a sample path with `rand!(rng, noises[i], yt)`, with a given random number generator `rng` and a vector of floats `yt` of size `n`, so that this sampling fills up the pre-allocated vector `yt` with a sample path over the interval `t0` to `tf`, with the corresponding resolution `dt = (tf - t0) / (n - 1)`. For that, we set up the `rng`, used for reproducibility.
This `noises` is a `Tuple` where each element is an OU sampler. With each sampler `noises[i]`, we draw a sample path with `rand!(rng, noises[i], yt)`, with a given random number generator `rng` and a vector of floats `yt` of size `n+1`, so that this sampling fills up the pre-allocated vector `yt` with a sample path over the interval `t0` to `tf`, with the corresponding resolution `dt = (tf - t0) / n`. For that, we set up the `rng`, used for reproducibility.

```@example colored
rng = Xoshiro(123)
Expand All @@ -81,8 +81,8 @@ rng = Xoshiro(123)
Let us visualize a sample path of these process. We define the resolution, pre-allocate some vectors, and compute the sample paths.

```@example colored
w_t = Vector{Float64}(undef, n) # for the white noise
ous_t = [Vector{Float64}(undef, n) for τ in τs] # for the OU noises
w_t = Vector{Float64}(undef, n+1) # for the white noise
ous_t = [Vector{Float64}(undef, n+1) for τ in τs] # for the OU noises
nothing # hide
```

Expand Down
6 changes: 3 additions & 3 deletions docs/src/noises/fBm.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ y0 = 0.0
t0 = 0.0
tf = 2.0
n = 2^9
tt = range(t0, tf, length=n)
tt = range(t0, tf, length=n+1)
nothing # hide
```

Expand All @@ -50,7 +50,7 @@ This `noise` is a `Dict` with the keys being the chosen Hurst parameters and wit

```@example fBm
rng = Xoshiro(123)
yt = Vector{Float64}(undef, n)
yt = Vector{Float64}(undef, n+1)
nothing # hide
```

Expand Down Expand Up @@ -109,7 +109,7 @@ nothing # hide
Now we generate the sets of sample paths for each Hurst parameter.

```@example fBm
W = Dict(H => Matrix{Float64}(undef, n, m) for H in Hs)
W = Dict(H => Matrix{Float64}(undef, n+1, m) for H in Hs)
for H in Hs
for i in 1:m
rand!(rng, noise[H], view(W[H], :, i))
Expand Down
8 changes: 4 additions & 4 deletions docs/src/noises/homlin.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ We start by setting the time interval, the mesh parameters, and the number of sa
t0 = 0.0
tf = 2.0
n = 2^10
tt = range(t0, tf, length=n)
dt = (tf - t0) / (n - 1)
tt = range(t0, tf, length=n+1)
dt = (tf - t0) / n
m = 200
nothing # hide
```
Expand All @@ -118,8 +118,8 @@ For comparison, we generate a bunch of sample paths with both constructors and c
```@example homlin
rng = Xoshiro(123)
gBmt = Matrix{Float64}(undef, n, m)
Yt = Matrix{Float64}(undef, n, m)
gBmt = Matrix{Float64}(undef, n+1, m)
Yt = Matrix{Float64}(undef, n+1, m)
for j in 1:m
rand!(rng, noise, view(gBmt, :, j))
Expand Down
Binary file modified latex/img/allnoises_combined.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified latex/img/noisepath_allnoises.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified latex/img/order_allnoises.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified latex/img/order_dep_on_H_fBm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified latex/img/riskmodel_surplus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fa56f24

Please sign in to comment.