Skip to content

Commit

Permalink
SRS
Browse files Browse the repository at this point in the history
  • Loading branch information
gottacatchenall committed Apr 26, 2024
1 parent fed5953 commit 07ed5be
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/simplerandom.jl
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

0 comments on commit 07ed5be

Please sign in to comment.