Dispatch on SamplerTrivial for rand method
Showing 2 of 2 files from the diff.
src/competing_poisson.jl
changed.
src/ContinuousTimeMarkov.jl
changed.
@@ -30,8 +30,8 @@
Loading
30 | 30 | CompetingPoisson(total_rate, Categorical(rates ./ total_rate), events) |
|
31 | 31 | end |
|
32 | 32 | ||
33 | - | function Base.rand(rng::AbstractRNG, cp::CompetingPoisson) |
|
34 | - | @unpack total_rate, index_distribution, events = cp |
|
33 | + | function Base.rand(rng::AbstractRNG, sampler::SamplerTrivial{<:CompetingPoisson}) |
|
34 | + | @unpack total_rate, index_distribution, events = sampler[] |
|
35 | 35 | τ = rand(rng, Exponential(1 / total_rate)) |
|
36 | 36 | i = rand(rng, index_distribution) |
|
37 | 37 | (duration = τ, event = events[i]) |
@@ -42,7 +42,6 @@
Loading
42 | 42 | private ? (:index_distribution, public...) : public |
|
43 | 43 | end |
|
44 | 44 | ||
45 | - | ||
46 | 45 | function Base.getproperty(cp::CompetingPoisson, key::Symbol) |
|
47 | 46 | if key ≡ :probabilities |
|
48 | 47 | probs(getfield(cp, :index_distribution)) |
@@ -8,7 +8,7 @@
Loading
8 | 8 | using DocStringExtensions: SIGNATURES |
|
9 | 9 | using Parameters: @unpack |
|
10 | 10 | using LinearAlgebra: Diagonal, lu, normalize! |
|
11 | - | using Random: AbstractRNG |
|
11 | + | using Random: AbstractRNG, SamplerTrivial |
|
12 | 12 | using SparseArrays: rowvals, nonzeros, nzrange, SparseMatrixCSC |
|
13 | 13 | ||
14 | 14 | include("transition_matrices.jl") |
Files | Coverage |
---|---|
src | 100.00% |
Project Totals (3 files) | 100.00% |
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.