-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fed5953
commit 07ed5be
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
SimpleRandom | ||
Implements Simple Random spatial sampling (each location has equal probability of selection) | ||
""" | ||
Base.@kwdef struct SimpleRandom{I <: Integer} <: BONSeeder | ||
numpoints::I = 50 | ||
function SimpleRandom(numpoints) | ||
if numpoints < one(numpoints) | ||
throw( | ||
ArgumentError( | ||
"You cannot have a SimpleRandom seeder with fewer than one point", | ||
), | ||
) | ||
end | ||
return new{typeof(numpoints)}(numpoints) | ||
end | ||
end | ||
|
||
function _generate!( | ||
coords::Vector{CartesianIndex}, | ||
sampler::SimpleRandom, | ||
uncertainty::Matrix{T}, | ||
) where {T <: AbstractFloat} | ||
pool = CartesianIndices(uncertainty) | ||
|
||
coords .= sample(pool, sampler.numpoints; replace = false) | ||
return (coords, uncertainty) | ||
end |