Skip to content
This repository has been archived by the owner on May 20, 2022. It is now read-only.

Commit

Permalink
Add option mean
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Mar 12, 2019
1 parent 5a91193 commit facbe67
Show file tree
Hide file tree
Showing 4 changed files with 7,764 additions and 3,758 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ os:
- linux
- osx
julia:
- 1.0
- 1.1
- nightly
matrix:
allow_failures:
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
julia 0.7
julia 1.1
GeoStatsBase 0.3.0
Variography 0.2.0
11,503 changes: 7,749 additions & 3,754 deletions docs/Usage.ipynb

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions src/DirectGaussianSimulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ LU decomposition of the covariance matrix.*
"""
@simsolver DirectGaussSim begin
@param variogram = GaussianVariogram()
@param mean = nothing
end

function preprocess(problem::SimulationProblem, solver::DirectGaussSim)
Expand Down Expand Up @@ -82,7 +83,14 @@ function preprocess(problem::SimulationProblem, solver::DirectGaussSim)
L₂₂ = cholesky(Symmetric(C₂₂ - A₂₁*B₁₂)).L
end

preproc[var] = (z₁, d₂, L₂₂, datalocs, simlocs)
if !isnothing(varparams.mean) && !isempty(datalocs)
@warn "mean can only be specified in unconditional simulation"
end

# mean for unconditional simulation
μ = isnothing(varparams.mean) ? zero(V) : varparams.mean

preproc[var] = (z₁, d₂, L₂₂, μ, datalocs, simlocs)
end

preproc
Expand All @@ -94,7 +102,7 @@ function solve_single(problem::SimulationProblem, var::Symbol,
pdomain = domain(problem)

# unpack preprocessed parameters
z₁, d₂, L₂₂, datalocs, simlocs = preproc[var]
z₁, d₂, L₂₂, μ, datalocs, simlocs = preproc[var]

# allocate memory for result
realization = Vector{eltype(z₁)}(undef, npoints(pdomain))
Expand All @@ -107,6 +115,9 @@ function solve_single(problem::SimulationProblem, var::Symbol,
y₂ = d₂ .+ L₂₂*w₂
realization[simlocs] = y₂

# adjust mean in case of unconditional simulation
isempty(datalocs) && (realization .+= μ)

realization
end

Expand Down

0 comments on commit facbe67

Please sign in to comment.