Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
EigenSolver committed Nov 8, 2024
1 parent 774023e commit 9a52ad2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
4 changes: 4 additions & 0 deletions docs/src/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ RandomFunction
CompositeRandomFunction
```

```@docs
initialize!
```

```@docs
characteristicfunction
```
Expand Down
34 changes: 23 additions & 11 deletions src/stochastics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ struct PinkLorentzianField <: GaussianRandomField
γ::Tuple{<:Real,<:Real} # cutoffs of 1/f
end

"""
Similar type of `RandomFunction` in Mathematica.
Can be used to generate a time series on a given time array subject to
a Gaussian random process traced from a Gaussian random field.
# Arguments
- `μ::Vector{<:Real}`: mean of the process
- `P::Vector{<:Point}`: time-position array
- `Σ::Symmetric{<:Real}`: covariance matrices
- `L::Matrix{<:Real}`: lower triangle matrix of Cholesky decomposition
"""
mutable struct RandomFunction
μ::Vector{<:Real}
P::Vector{<:Point} # sample trace
Σ::Symmetric{<:Real} # covariance matrices
L::Union{Matrix{<:Real}, Nothing} # Lower triangle matrix of Cholesky decomposition
"""
Create a new `RandomFunction` instance.
# Arguments
- `P::Vector{<:Point}`: Sample trace.
- `process::GaussianRandomField`: The Gaussian random field process.
- `initialize::Bool=true`: Whether to initialize the Cholesky decomposition of the covariance matrix.
# Returns
A new `RandomFunction` instance.
"""
function RandomFunction(P::Vector{<:Point}, process::GaussianRandomField; initialize::Bool=true)
μ = process.μ isa Function ? process.μ(P) : repeat([process.μ], length(P))
Σ = covariancematrix(P, process)
Expand All @@ -55,6 +55,18 @@ mutable struct RandomFunction
return new(μ, P, Σ, L)
end

"""
Create a new `RandomFunction` instance with precomputed values.
# Arguments
- `μ::Vector{<:Real}`: Mean vector.
- `P::Vector{<:Point}`: Sample trace.
- `Σ::Symmetric{<:Real}`: Covariance matrix.
- `L::Matrix{<:Real}`: Lower triangle matrix of Cholesky decomposition.
# Returns
A new `RandomFunction` instance.
"""
function RandomFunction::Vector{<:Real}, P::Vector{<:Point}, Σ::Symmetric{<:Real}, L::Matrix{<:Real})
new(μ, P, Σ, L)
end
Expand Down

0 comments on commit 9a52ad2

Please sign in to comment.