@@ -11,7 +11,6 @@ define `λ` as a function or vector of values. If `λ` is a vector, it is
1111assumed that the process is associated with a `Domain` with the same
1212number of elements as `λ`.
1313"""
14-
1514struct PoissonProcess{L<: Union{Real,Function,AbstractVector} } <: PointProcess
1615 λ:: L
1716end
@@ -27,10 +26,13 @@ Base.union(p₁::PoissonProcess{<:Function}, p₂::PoissonProcess{<:Real}) = Poi
2726Base. union (p₁:: PoissonProcess{<:AbstractVector} , p₂:: PoissonProcess{<:AbstractVector} ) = PoissonProcess (x -> p₁. λ + p₂. λ)
2827
2928ishomogeneous (p:: PoissonProcess{<:Real} ) = true
29+
3030ishomogeneous (p:: PoissonProcess{<:Function} ) = false
31+
3132ishomogeneous (p:: PoissonProcess{<:AbstractVector} ) = false
3233
3334default_sampling_algorithm (:: PoissonProcess , :: Any ) = DiscretizedSampling ()
35+
3436default_sampling_algorithm (p:: PoissonProcess{<:Function} , g) = ThinnedSampling (default_lambda_max (p, g))
3537
3638function default_lambda_max (p:: PoissonProcess{<:Function} , g)
6567# INHOMOGENEOUS CASE
6668# --------------------
6769
70+ function rand_single (rng:: Random.AbstractRNG , p:: PoissonProcess{<:Function} , g, algo:: ThinnedSampling )
71+ # simulate a homogeneous process
72+ pp = rand_single (rng, PoissonProcess (algo. λmax), g, DiscretizedSampling ())
73+
74+ # thin point pattern
75+ thin (pp, RandomThinning (x -> p. λ (x) / algo. λmax))
76+ end
77+
78+ function rand_single (rng:: Random.AbstractRNG , p:: PoissonProcess{<:Function} , d:: Domain , algo:: DiscretizedSampling )
79+ # compute intensity on centroids
80+ c = centroid .(d)
81+ λvec = p. λ .(c)
82+
83+ # simulate inhomogeneous process
84+ rand_single (rng, PoissonProcess (λvec), d, algo)
85+ end
86+
6887function rand_single (rng:: Random.AbstractRNG , p:: PoissonProcess{<:AbstractVector} , d:: Domain , algo:: DiscretizedSampling )
6988 # simulate number of points
7089 λ = p. λ
@@ -86,20 +105,3 @@ function rand_single(rng::Random.AbstractRNG, p::PoissonProcess{<:AbstractVector
86105 PointSet (points)
87106 end
88107end
89-
90- function rand_single (rng:: Random.AbstractRNG , p:: PoissonProcess{<:Function} , g, algo:: ThinnedSampling )
91- # simulate a homogeneous process
92- pp = rand_single (rng, PoissonProcess (algo. λmax), g, DiscretizedSampling ())
93-
94- # thin point pattern
95- thin (pp, RandomThinning (x -> p. λ (x) / algo. λmax))
96- end
97-
98- function rand_single (rng:: Random.AbstractRNG , p:: PoissonProcess{<:Function} , d:: Domain , algo:: DiscretizedSampling )
99- # compute intensity on centroids
100- c = centroid .(d)
101- λvec = p. λ .(c)
102-
103- # simulate inhomogeneous process
104- rand_single (rng, PoissonProcess (λvec), d, algo)
105- end
0 commit comments