Skip to content

Commit 180362c

Browse files
committed
Fix grid PRS for hard core point process
1 parent 7cbfd6f commit 180362c

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/hard_core_spatial.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ function generate_sample_prs(
7777
rng = getRNG(rng)
7878
window_ = win === nothing ? window(hc) : win
7979

80-
n = rand(rng, Distributions.Poisson(hc.β))
81-
points = hcat((rand(window_; rng=rng) for _ in 1:n)...)
80+
n = rand(rng, Distributions.Poisson(hc.β * volume(window_)))
81+
points = Matrix{Float64}(undef, dimension(hc), n)
82+
for x in eachcol(points)
83+
x .= rand(window_; rng=rng)
84+
end
85+
8286
while true
8387
bad = vec(any(pairwise_distances(points) .< hc.r, dims=2))
8488
!any(bad) && break
@@ -155,11 +159,11 @@ Pairwise distance matrix between columns of `X` and `Y`.
155159
Equivalent to `[norm(x - y) for x in X, y in Y]`.
156160
"""
157161
function pairwise_distances(X, Y)
158-
return Distances.pairwise(Distances.Euclidean(1e-8), X, Y, dims=2)
162+
return Distances.pairwise(Distances.Euclidean(1e-8), X, Y; dims=2)
159163
end
160164

161165
function pairwise_distances(X)
162-
dist = Distances.pairwise(Distances.Euclidean(1e-8), X, dims=2)
166+
dist = Distances.pairwise(Distances.Euclidean(1e-8), X; dims=2)
163167
dist[LA.diagind(dist)] .= Inf
164168
return dist
165169
end

test/hard_core_spatial.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ win = PRS.SquareWindow(c, w)
1111
hc = PRS.HardCorePointProcess(b, r, win)
1212

1313
@time sample = PRS.generate_sample_prs(hc; rng=-1)
14-
# Todo @time sample = PRS.generate_sample_grid_prs(hc; rng=-1)
14+
# @time sample = PRS.generate_sample_grid_prs(hc; rng=-1)
1515

1616
p = PRS.plot(hc, sample; title="")

0 commit comments

Comments
 (0)