Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/PointProcesses.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export HypothesisTest, pvalue # HypothesisTests

## History

export History
export event_times, event_marks, min_time, max_time, min_mark, max_mark
export History, UnivariateHistory
export event_times, event_marks, event_dims
export min_time, max_time, min_mark, max_mark, n_dims
export nb_events, has_events, duration
export time_change, split_into_chunks

Expand Down
10 changes: 5 additions & 5 deletions src/hawkes/hawkes_process.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function simulate(rng::AbstractRNG, hp::HawkesProcess, tmin, tmax)
sim_desc = generate_descendants(rng, sim, tmax, hp.α, hp.ω) # Recursively generates descendants from first events
append!(sim, sim_desc)
sort!(sim)
return History(; times=sim, tmin=tmin, tmax=tmax, check=false)
return History(sim, tmin, tmax, check_args=false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
return History(sim, tmin, tmax, check_args=false)
return History(sim, tmin, tmax; check_args=false)

end

"""
Expand Down Expand Up @@ -78,7 +78,7 @@ therefore, the interval of the process is transformed from T to N. Also, in equa
"""
function StatsAPI.fit(
::Type{HawkesProcess{T}},
h::History;
h::UnivariateHistory;
step_tol::Float64=1e-6,
max_iter::Int=1000,
rng::AbstractRNG=default_rng(),
Expand Down Expand Up @@ -149,12 +149,12 @@ function StatsAPI.fit(
end

# Type parameter for `HawkesProcess` was NOT explicitly provided
function StatsAPI.fit(HP::Type{HawkesProcess}, h::History{H,M}; kwargs...) where {H<:Real,M}
function StatsAPI.fit(HP::Type{<:HawkesProcess}, h::UnivariateHistory{H,M}; kwargs...) where {H<:Real,M}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[JuliaFormatter] reported by reviewdog 🐶

Suggested change
function StatsAPI.fit(HP::Type{<:HawkesProcess}, h::UnivariateHistory{H,M}; kwargs...) where {H<:Real,M}
function StatsAPI.fit(
HP::Type{<:HawkesProcess}, h::UnivariateHistory{H,M}; kwargs...
) where {H<:Real,M}

T = promote_type(Float64, H)
return fit(HP{T}, h; kwargs...)
end

function time_change(h::History{R,M}, hp::HawkesProcess) where {R<:Real,M}
function time_change(h::UnivariateHistory{R,M}, hp::HawkesProcess) where {R<:Real,M}
T = float(R)
n = nb_events(h)
n == 0 && return History(T[], zero(T), T(hp.μ * duration(h)), event_marks(h))
Expand All @@ -178,7 +178,7 @@ function time_change(h::History{R,M}, hp::HawkesProcess) where {R<:Real,M}
times .+= T.(hp.μ .* (h.times .- h.tmin))
tmax += T(hp.μ * duration(h))

return History(; times=times, marks=h.marks, tmin=zero(T), tmax=tmax, check=false) # A time re-scaled process starts at t=0
return History(times, zero(T), tmax, event_marks(h); check_args=false) # A time re-scaled process starts at t=0
end

function ground_intensity(hp::HawkesProcess, h::History, t)
Expand Down
Loading
Loading