Skip to content

Commit 28a6483

Browse files
committed
test: cover truncated continuous delays in convolve_series
Adds a testitem verifying a truncated delay convolved via double_interval_censored differs from the untruncated result and that the truncated grid PMF is normalised.
1 parent a4cd83e commit 28a6483

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/integration/ConvolvedDistributions.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,27 @@ end
186186
dic = [double_interval_censored(d; interval = 1) for d in raw]
187187
@test convolve_series(raw, series) convolve_series(dic, series)
188188
end
189+
190+
@testitem "convolve_series: truncated continuous delay" begin
191+
using CensoredDistributions
192+
using ConvolvedDistributions: convolve_series
193+
using Distributions
194+
195+
# A truncated delay passed to convolve_series is discretised via
196+
# double_interval_censored (truncation applied before secondary interval
197+
# censoring). Verify the result differs from the untruncated delay and
198+
# that truncation via the lower/upper keywords is honoured.
199+
series = [0.0, 1.0, 3.0, 6.0, 8.0, 5.0, 2.0]
200+
201+
# Truncation configured through double_interval_censored, then convolved.
202+
truncated_delay = double_interval_censored(LogNormal(1.5, 0.75);
203+
lower = 0.5, upper = 5.0, interval = 1)
204+
result = convolve_series(truncated_delay, series)
205+
206+
untruncated = convolve_series(LogNormal(1.5, 0.75), series)
207+
@test result != untruncated
208+
209+
# The truncated PMF has no mass outside [0.5, 5.0].
210+
masses = CensoredDistributions._grid_pmf(truncated_delay, length(series))
211+
@test sum(masses) 1.0 atol = 1e-6
212+
end

0 commit comments

Comments
 (0)