Conversation
- Change the models to hold vectors of parameters instead of single
parameters
- Update methods to return multivariate histories
- Update tests
Steps
- Update general interface for `AbstractPointProcess`
- Update `simulation.jl`
- Update homogeneous Poisson and related methods
- Update inhomogeneous Poisson and related methods
- Update hypothesis tests
- They work only for univariate processes. Generalization for the
futrue
- Ignore Hawkes processes, since they will be implemented in another PR
- Takes an array of parameters - Methods like `ground_intensity` return an array - Added methods with an argument `d::Int` to get the values from specific dimensions
This reverts commit 90f08d6. Instead of making all processes multivariate, implement tem separately. - `AbstractMultivariateProcess` - `IndependenteMultivariateProcess` - `DependentMultivariateProcess`? - Other processes, such as `MultivariateHawkesProcess`
Univariate and multivariate processes are different types. Implementation for univariate processes remained unchanged.
There was a problem hiding this comment.
Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit
JuliaFormatter
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/inhomogeneous_poisson_process.jl
Lines 860 to 862 in 1f8fdd7
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/inhomogeneous_poisson_process.jl
Lines 896 to 898 in 1f8fdd7
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/inhomogeneous_poisson_process.jl
Lines 919 to 921 in 1f8fdd7
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/inhomogeneous_poisson_process.jl
Lines 946 to 948 in 1f8fdd7
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/inhomogeneous_poisson_process.jl
Lines 968 to 970 in 1f8fdd7
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/inhomogeneous_poisson_process.jl
Lines 1143 to 1144 in 1f8fdd7
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/multivariate_poisson_process.jl
Lines 70 to 71 in 1f8fdd7
[JuliaFormatter] reported by reviewdog 🐶
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/poisson_process.jl
Line 78 in 1f8fdd7
[JuliaFormatter] reported by reviewdog 🐶
PointProcesses.jl/test/poisson_process.jl
Line 83 in 1f8fdd7
| ground_intensity_bound(bpp::BoundedPointProcess, args...) = ground_intensity_bound(bpp.pp, args...) | ||
| integrated_ground_intensity(bpp::BoundedPointProcess, args...) = integrated_ground_intensity(bpp.pp, args...) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| ground_intensity_bound(bpp::BoundedPointProcess, args...) = ground_intensity_bound(bpp.pp, args...) | |
| integrated_ground_intensity(bpp::BoundedPointProcess, args...) = integrated_ground_intensity(bpp.pp, args...) | |
| function ground_intensity_bound(bpp::BoundedPointProcess, args...) | |
| ground_intensity_bound(bpp.pp, args...) | |
| end | |
| function integrated_ground_intensity(bpp::BoundedPointProcess, args...) | |
| integrated_ground_intensity(bpp.pp, args...) | |
| end |
| vec_dims = vcat(dims...) | ||
| end | ||
| return History( | ||
| vec_times[perm], tmin, tmax, vec_marks[perm], vec_dims[perm], length(times); check_args=check_args |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| vec_times[perm], tmin, tmax, vec_marks[perm], vec_dims[perm], length(times); check_args=check_args | |
| vec_times[perm], | |
| tmin, | |
| tmax, | |
| vec_marks[perm], | |
| vec_dims[perm], | |
| length(times); | |
| check_args=check_args, |
|
|
||
| Return the sorted vector of event times for `h` in dimension `d`. | ||
| """ | ||
| event_times(h::History, d::Int) = h.N == 1 && d == 1 ? h.times : (@view h.times[h.dims .== d]) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| event_times(h::History, d::Int) = h.N == 1 && d == 1 ? h.times : (@view h.times[h.dims .== d]) | |
| function event_times(h::History, d::Int) | |
| h.N == 1 && d == 1 ? h.times : (@view h.times[h.dims .== d]) | |
| end |
| times = event_times(h, d)::AbstractVector | ||
| i_min = searchsortedfirst(times, tmin) | ||
| i_max = searchsortedfirst(times, tmax) | ||
| return @view times[i_min : (i_max - 1)] |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| return @view times[i_min : (i_max - 1)] | |
| return @view times[i_min:(i_max - 1)] |
|
|
||
| Return the vector of event marks in dimension `d` of `h`, sorted according to their event times. | ||
| """ | ||
| event_marks(h::History, d::Int) = h.N == 1 && d == 1 ? h.marks : (@view h.marks[h.dims .== d]) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| event_marks(h::History, d::Int) = h.N == 1 && d == 1 ? h.marks : (@view h.marks[h.dims .== d]) | |
| function event_marks(h::History, d::Int) | |
| h.N == 1 && d == 1 ? h.marks : (@view h.marks[h.dims .== d]) | |
| end |
| vcat, (fill(w, nb_events(h)) for (w, h) in zip(weights, histories)) | ||
| ) | ||
| return PoissonProcessStats(total_nb_events, total_duration, total_marks, total_weights) | ||
| return PoissonProcessStats(total_nb_events, total_duration, total_marks, total_dims, total_weights) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| return PoissonProcessStats(total_nb_events, total_duration, total_marks, total_dims, total_weights) | |
| return PoissonProcessStats( | |
| total_nb_events, total_duration, total_marks, total_dims, total_weights | |
| ) |
| InhomogeneousPoissonProcess{ | ||
| ExponentialIntensity{Float64},Normal,IntegrationConfig | ||
| }, |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| InhomogeneousPoissonProcess{ | |
| ExponentialIntensity{Float64},Normal,IntegrationConfig | |
| }, | |
| InhomogeneousPoissonProcess{ExponentialIntensity{Float64},Normal,IntegrationConfig}, |
| @test 0.5 * intensity_true.a <= | ||
| pp_est.intensity_function.a <= | ||
| 3.0 * intensity_true.a |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| @test 0.5 * intensity_true.a <= | |
| pp_est.intensity_function.a <= | |
| 3.0 * intensity_true.a | |
| @test 0.5 * intensity_true.a <= pp_est.intensity_function.a <= 3.0 * intensity_true.a |
| InhomogeneousPoissonProcess{ | ||
| SinusoidalIntensity{Float64},Uniform,IntegrationConfig | ||
| }, |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| InhomogeneousPoissonProcess{ | |
| SinusoidalIntensity{Float64},Uniform,IntegrationConfig | |
| }, | |
| InhomogeneousPoissonProcess{SinusoidalIntensity{Float64},Uniform,IntegrationConfig}, |
| intensity_cov3 = LinearCovariateIntensity( | ||
| 2.0, [0.1, 0.2, 0.3], [cov1, cov2, cov3] | ||
| ) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| intensity_cov3 = LinearCovariateIntensity( | |
| 2.0, [0.1, 0.2, 0.3], [cov1, cov2, cov3] | |
| ) | |
| intensity_cov3 = LinearCovariateIntensity(2.0, [0.1, 0.2, 0.3], [cov1, cov2, cov3]) |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
| # Fields | ||
| - `processes::Vector{P}`: vector of univariate point processes, one for each dimension. | ||
| """ | ||
| struct IndependentMultivariateProcess{P<:AbstractUnivariateProcess} <: AbstractMultivariateProcess |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| struct IndependentMultivariateProcess{P<:AbstractUnivariateProcess} <: AbstractMultivariateProcess | |
| struct IndependentMultivariateProcess{P<:AbstractUnivariateProcess} <: | |
| AbstractMultivariateProcess |
| return [mark_distribution(pp.processes[d], t) for d in 1:ndims(pp)] | ||
| end | ||
|
|
||
| function intensity(pp::IndependentMultivariateProcess, m, t, h, d) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| function intensity(pp::IndependentMultivariateProcess, m, t, h, d) | |
| function intensity(pp::IndependentMultivariateProcess, m, t, h, d) |
| return intensity(pp.processes[d], m, t, h) | ||
| end | ||
|
|
||
| function intensity(pp::IndependentMultivariateProcess, m, t, h) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| function intensity(pp::IndependentMultivariateProcess, m, t, h) | |
| function intensity(pp::IndependentMultivariateProcess, m, t, h) |
| return [intensity(pp, m, t, h, d) for d in 1:ndims(pp)] | ||
| end | ||
|
|
||
| log_intensity(pp::IndependentMultivariateProcess, m, t, h, d) = log(intensity(pp, m, t, h, d)) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| log_intensity(pp::IndependentMultivariateProcess, m, t, h, d) = log(intensity(pp, m, t, h, d)) | |
| function log_intensity(pp::IndependentMultivariateProcess, m, t, h, d) | |
| log(intensity(pp, m, t, h, d)) | |
| end |
| end | ||
|
|
||
| function DensityInterface.logdensityof(pp::IndependentMultivariateProcess, h::History) | ||
| return sum(logdensityof(pp.processes[d], History(event_times(h, d), h.tmin, h.tmax, event_marks(h, d))) for d in 1:ndims(pp)) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| return sum(logdensityof(pp.processes[d], History(event_times(h, d), h.tmin, h.tmax, event_marks(h, d))) for d in 1:ndims(pp)) | |
| return sum( | |
| logdensityof( | |
| pp.processes[d], History(event_times(h, d), h.tmin, h.tmax, event_marks(h, d)) | |
| ) for d in 1:ndims(pp) | |
| ) |
| @test mark_distribution(pp1, 0, h, 2) == mark_dists[2] | ||
| @test intensity(pp1, 0, 0, h) == [intensity(pp1.processes[d], 0, 0, h) for d in 1:ndims(pp1)] | ||
| @test intensity(pp1, 0, 0, h, 1) == intensity(pp1.processes[1], 0, 0, h) | ||
| @test log_intensity(pp1, 0, 0, h) ≈ [log_intensity(pp1.processes[d], 0, 0, h) for d in 1:ndims(pp1)] |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| @test log_intensity(pp1, 0, 0, h) ≈ [log_intensity(pp1.processes[d], 0, 0, h) for d in 1:ndims(pp1)] | |
| @test log_intensity(pp1, 0, 0, h) ≈ | |
| [log_intensity(pp1.processes[d], 0, 0, h) for d in 1:ndims(pp1)] |
| pp_est1 = fit(fill(PoissonProcess{Float64, Normal}, 3), h1) | ||
| pp_est2 = fit(fill(PoissonProcess{Float64, Normal}, 3), h2) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| pp_est1 = fit(fill(PoissonProcess{Float64, Normal}, 3), h1) | |
| pp_est2 = fit(fill(PoissonProcess{Float64, Normal}, 3), h2) | |
| pp_est1 = fit(fill(PoissonProcess{Float64,Normal}, 3), h1) | |
| pp_est2 = fit(fill(PoissonProcess{Float64,Normal}, 3), h2) |
|
|
||
| @test l isa Real | ||
| @test isfinite(l) | ||
| end No newline at end of file |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| end | |
| end | |
| @test σ_error1 < 0.1 | ||
| @test μ_error2 < 0.1 | ||
| @test σ_error2 < 0.1 | ||
|
|
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| l = logdensityof(pp, h1) | ||
| l_est = logdensityof(pp_est1, h1) | ||
| @test l_est > l | ||
| end No newline at end of file |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| end | |
| end | |
| @test event_marks(h_multi) == ["a", "c", "b", "d"] | ||
| @test event_dims(h_multi) == [1, 2, 1, 2] | ||
|
|
||
| @test_throws DomainError History(rand(3), 0, 1, rand(3), [1,2,3], 2) |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| @test_throws DomainError History(rand(3), 0, 1, rand(3), [1,2,3], 2) | |
| @test_throws DomainError History(rand(3), 0, 1, rand(3), [1, 2, 3], 2) |
| @test nb_events(h_multi) == 7 | ||
| @test event_times(h_multi, 1) == [0.1, 0.5, 0.85, 0.9] | ||
| @test event_marks(h_multi, 1) == ["a", "b", "e", "g"] | ||
| end No newline at end of file |
There was a problem hiding this comment.
[JuliaFormatter] reported by reviewdog 🐶
| end | |
| end | |
Implementation of multivariate processes. Discussion in Issue #73
HistoryContains an array
timeswith the event times, an arraymarkswith corresponding marks, and another arraydimswith corresponding dimensionUnivariatePointProcessandMultivariatePointProcessAll previous implementations remained unchanged, but now these processes are subtypes of
UnivariatePointProcess.Multivariate processes were implemented separetely as
MultivariatePointProcess. This allowed the implementation ofIndependentMultivariateProcessandMultivariatePoissonProcesssimply using an array of univariate processes.