Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create xexpy function with x = 1 typestable #473

Merged
merged 1 commit into from
Oct 4, 2024
Merged
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
2 changes: 1 addition & 1 deletion EpiAware/src/EpiInfModels/EpiInfModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module EpiInfModels
using ..EpiAwareBase
using ..EpiAwareUtils

using Turing, Distributions, DocStringExtensions, LinearAlgebra
using Turing, Distributions, DocStringExtensions, LinearAlgebra, LogExpFunctions

#Export models
export EpiData, DirectInfections, ExpGrowthRate, Renewal
Expand Down
2 changes: 1 addition & 1 deletion EpiAware/src/EpiInfModels/ExpGrowthRate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ I_t = generated_quantities(latent_inf, θ)
"
@model function EpiAwareBase.generate_latent_infs(epi_model::ExpGrowthRate, rt)
init_incidence ~ epi_model.initialisation_prior
return exp.(init_incidence .+ cumsum(rt))
return oneexpy.(init_incidence .+ cumsum(rt))
end
7 changes: 7 additions & 0 deletions EpiAware/src/EpiInfModels/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,10 @@ Compute the reproductive ratio given exponential growth rate `r`
function r_to_R(r, w::AbstractVector)
return 1 / neg_MGF(r, w::AbstractVector)
end

"""
Version of `LogExpFunctions.xexpy` that takes a single argument `y` and returns `exp(y)`.
"""
function oneexpy(y::T) where {T}
return xexpy(one(T), y)
end
Loading