Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

Commit 5ed4e30

Browse files
committed
Add ishomogeneous trait
1 parent d8889d7 commit 5ed4e30

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

src/PointPatterns.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export
2525
PointProcess,
2626
BinomialProcess,
2727
PoissonProcess,
28-
UnionProcess
28+
UnionProcess,
29+
ishomogeneous
2930

3031
end # module

src/processes.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ A spatial point process.
99
"""
1010
abstract type PointProcess end
1111

12+
"""
13+
ishomogeneous(p)
14+
15+
Tells whether or not the spatial point process `p` is homogeneous.
16+
"""
17+
ishomogeneous(p::PointProcess) = false
18+
1219
"""
1320
rand(p, r, n=1)
1421

src/processes/binomial.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ struct BinomialProcess <: PointProcess
1111
n::Int
1212
end
1313

14+
ishomogeneous(p::BinomialProcess) = true
15+
1416
function rand_single(p::BinomialProcess, r::RectangleRegion{T,N}) where {N,T}
1517
# region configuration
1618
lo = lowerleft(r)

src/processes/poisson.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@
77
88
A Poisson process with intensity `λ`.
99
"""
10-
struct PoissonProcess{L} <: PointProcess
10+
struct PoissonProcess{L<:Union{Real,Function}} <: PointProcess
1111
λ::L
1212
end
1313

14-
function rand_single(p::PoissonProcess, r::RectangleRegion{T,N}) where {N,T}
14+
ishomogeneous(p::PoissonProcess{<:Real}) = true
15+
16+
# homogeneous case
17+
function rand_single(p::PoissonProcess{<:Real}, r::RectangleRegion{T,N}) where {N,T}
1518
# region configuration
1619
lo = lowerleft(r)
1720
up = upperright(r)
1821

1922
# simulate number of points
20-
λ = p.λ
21-
V = volume(r)
23+
λ = p.λ; V = volume(r)
2224
n = rand(Poisson*V))
2325

2426
# product of uniform distributions
@@ -28,4 +30,9 @@ function rand_single(p::PoissonProcess, r::RectangleRegion{T,N}) where {N,T}
2830
PointPattern(rand(U, n))
2931
end
3032

33+
# inhomogeneous case
34+
function rand_single(p::PoissonProcess{<:Function}, r::RectangleRegion{T,N}) where {N,T}
35+
# TODO
36+
end
37+
3138
Base.union(p₁::PoissonProcess, p₂::PoissonProcess) = PoissonProcess(p₁.λ + p₂.λ)

src/processes/union.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ struct UnionProcess{P₁<:PointProcess,P₂<:PointProcess} <: PointProcess
1212
p₂::P₂
1313
end
1414

15+
ishomogeneous(p::UnionProcess) = ishomogeneous(p.p₁) && ishomogeneous(p.p₂)
16+
1517
function rand_single(p::UnionProcess, r::AbstractRegion)
1618
pp₁ = rand(p.p₁, r)
1719
pp₂ = rand(p.p₂, r)

0 commit comments

Comments
 (0)