Skip to content

Commit

Permalink
Transform functions to methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Faik1995 committed Sep 6, 2024
1 parent f552d3b commit 68e41f6
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 105 deletions.
6 changes: 3 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ When ``\epsilon`` converges to zero, then, by homogenization theory, the process
```
where ``K>0`` is a corrective constant that comes from the cell problem of the homogenization, see also [`K`](@ref). The task is to estimate the parameter ``\vartheta := \alpha K``
through data that comes in form of a long trajectory of the process ``X_\epsilon`` with "small" ``\epsilon > 0``. We will use the [`MDE`](@ref) for the estimation. First, we generate synthetic
data with the function [`Langevin_ϵ`](@ref). The plot of a trajectory, created with [`produce_trajectory`](@ref), looks like the following.
data with the function [`Langevin`](@ref). The plot of a trajectory, created with [`produce_trajectory`](@ref), looks like the following.
```@example
# quadratic potential V with sine oscillation p
using MDEforM # hide
import Random # hide
Random.seed!(1111) # hide
T = 10
trajectory = Langevin_ϵ(5.0, func_config=LDO(), α=2.0, σ=1.0, ϵ=0.1, T=T)
trajectory = Langevin(5.0, 10.0, func_config=LDO(), α=2.0, σ=1.0, ϵ=0.1, T=T)
fig = produce_trajectory(trajectory, T)
```

Expand All @@ -90,7 +90,7 @@ We now increase the time horizon ``T`` to obtain accurate estimates for ``\varth
using MDEforM # hide
import Random # hide
Random.seed!(1111) # hide
data = Langevin_ϵ(5.0, func_config=LDO(), α=2.0, σ=1.0, ϵ=0.1, T=1000)[1] # only slow process
data = Langevin(5.0, 10.0, func_config=LDO(), α=2.0, σ=1.0, ϵ=0.1, T=1000)[1] # only slow process
nothing # hide
```
Under this configuration the true parameter ``\vartheta`` is given by
Expand Down
14 changes: 4 additions & 10 deletions docs/src/multiscale_limit_pairs.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,16 @@ The majority of the following functions give realizations of the multiscale proc

## Functions
```@docs
Fast_OU_ϵ
Fast_OU_∞
Fast_OU
LDA
NLDAM
NSDP
Langevin_ϵ
Langevin
K
Langevin_∞
LDO
NLDO
Langevin_ϵ_2D
Langevin_∞_2D
Burger_ϵ
Burger_∞
Fast_chaotic_ϵ
Fast_chaotic_∞
Burger
Fast_chaotic
produce_trajectory
```

Expand Down
6 changes: 3 additions & 3 deletions src/MDE_functionals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ $ julia --threads 10 --project=. # start julia with 10 threads and activate proj
```julia-repl
julia> Threads.nthreads()
julia> using MDEforM
julia> data = Langevin_ϵ(1.0, func_config=NLDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> data = Langevin(1.0, 0.0, func_config=NLDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> Δ(data, 1, 1, NLDO()[1])
```
Expand Down Expand Up @@ -163,7 +163,7 @@ See the main manuscript for details on this functional. It is the core object of
# Examples
```julia-repl
julia> using MDEforM
julia> data = Langevin_ϵ(1.0, func_config=LDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> data = Langevin(1.0, 0.0, func_config=LDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> Δ_Gaussian1D(data, 1, 1)
```
Expand Down Expand Up @@ -239,7 +239,7 @@ and is given by the covariance matrix of the invariant Gaussian density, and ``\
julia> using MDEforM
julia> M=[4 2;2 3]
julia> σ = 5.0
julia> data = Langevin_ϵ_2D([-5.0, -5.0], func_config=(x-> cos(x), x -> 1/2*cos(x)), M=M, σ=σ, ϵ=0.1, T=100.0)[1]
julia> data = Langevin([-5.0, -5.0], [0.0, 0.0], func_config=(x-> cos(x), x -> 1/2*cos(x)), M=M, σ=σ, ϵ=0.1, T=100.0)[1]
julia> CorrK = [K(x-> cos(x), σ) 0 ; 0 K(x -> 1/2*cos(x), σ)]
julia> ϑ = CorrK*M
julia> Σ = σ*CorrK
Expand Down
6 changes: 3 additions & 3 deletions src/MDE_gradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ $ julia --threads 10 --project=. # start julia with 10 threads and activate proj
```julia-repl
julia> Threads.nthreads()
julia> using MDEforM
julia> data = Langevin_ϵ(1.0, func_config=NLDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> data = Langevin(1.0, 0.0, func_config=NLDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> Δ_grad_ϑ(data, 1, 1, NLDO()[1])
```
Expand Down Expand Up @@ -177,7 +177,7 @@ $ julia --threads 10 --project=. # start julia with 10 threads and activate proj
```julia-repl
julia> Threads.nthreads()
julia> using MDEforM
julia> data = Langevin_ϵ(1.0, func_config=NLDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> data = Langevin(1.0, 0.0, func_config=NLDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> Δ_grad_Σ(data, 1, 1, NLDO()[1])
```
Expand Down Expand Up @@ -217,7 +217,7 @@ is implemented. Here, ``X_ϵ`` is a one-dimensional time series of length ``T``,
# Examples
```julia-repl
julia> using MDEforM
julia> data = Langevin_ϵ(1.0, func_config=LDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> data = Langevin(1.0, 0.0, func_config=LDO(), α=2.0, σ=1.0, ϵ=0.1, T=100)[1]
julia> Δ_Gaussian1D_grad(data, 1, 1)
```
Expand Down
6 changes: 3 additions & 3 deletions src/MDE_optimizers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ is, in the given case, quadratic, i.e. ``V(x)=x^2/2``.
```julia-repl
julia> using MDEforM
julia> limit_drift_parameter = 1.0
julia> data = Fast_chaotic_ϵ([1.0, 1.0, 1.0, 1.0], A=-limit_drift_parameter, B=0.0, λ=2/45, ϵ=0.1, T=1000)
julia> data = Fast_chaotic([1.0, 1.0, 1.0, 1.0], A=-limit_drift_parameter, B=0.0, λ=2/45, ϵ=0.1, T=1000)
julia> MDE(data, "Fast Chaotic Noise", limit_drift_parameter, 10.0)
```
Expand Down Expand Up @@ -118,7 +118,7 @@ $ julia --threads 10 --project=. # start julia with 10 threads and activate proj
```julia-repl
julia> using MDEforM
julia> limit_drift_parameter = 1.0
julia> data = Fast_chaotic_ϵ([1.0, 1.0, 1.0, 1.0], A=limit_drift_parameter, B=1.0, λ=2/45, ϵ=10^(-3/2), T=100)
julia> data = Fast_chaotic([1.0, 1.0, 1.0, 1.0], A=limit_drift_parameter, B=1.0, λ=2/45, ϵ=10^(-3/2), T=100)
julia> V = NLDO()[1]
julia> MDE(data, "Fast Chaotic Noise", V, limit_drift_parameter, 0.8)
```
Expand Down Expand Up @@ -203,7 +203,7 @@ julia> p1_prime, p2_prime = (x-> cos(x), x -> 1/2*cos(x))
julia> CorrK = [K(p1, σ) 0 ; 0 K(p2, σ)]
julia> A = CorrK*M # true parameter; the parameter that ought to be estimated
julia> Σ = σ*CorrK
julia> data = Langevin_ϵ_2D([-5.0, -5.0], func_config=(p1_prime, p2_prime), M=M, σ=σ, ϵ=0.1, T=1000)[1]
julia> data = Langevin([-5.0, -5.0], [0.0, 0.0], func_config=(p1_prime, p2_prime), M=M, σ=σ, ϵ=0.1, T=1000)[1]
julia> ϑ_initial = [3.0 0.5*Σ[1]; 0.5*Σ[4] 6.0]
julia> MDE(data, Σ, ϑ_initial)
```
Expand Down
9 changes: 4 additions & 5 deletions src/MDEforM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ using NaNMath
using QuadGK

# main code
export Fast_OU_ϵ, Fast_OU_∞, LDA, NLDAM, NSDP
export Langevin_ϵ, Langevin_∞, K, LDO, NLDO
export Langevin_ϵ_2D, Langevin_∞_2D
export Burger_ϵ, Burger_∞
export Fast_chaotic_ϵ, Fast_chaotic_∞
export Fast_OU, LDA, NLDAM, NSDP
export Langevin, K, LDO, NLDO
export Burger
export Fast_chaotic
export produce_trajectory

include("multiscale_limit_pairs.jl")
Expand Down
Loading

0 comments on commit 68e41f6

Please sign in to comment.