Skip to content

Commit

Permalink
Simplify hist_loglike
Browse files Browse the repository at this point in the history
  • Loading branch information
fhagemann committed Aug 26, 2024
1 parent 4cf28bd commit 8dd6e84
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/likelihoods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ bins of `h`.
function hist_loglike(f_fit::Base.Callable, h::Histogram{<:Real,1})
bin_edges = first(h.edges)
counts = h.weights
bin_centers = (bin_edges[begin:end-1] .+ bin_edges[begin+1:end]) ./ 2
bin_widths = bin_edges[begin+1:end] .- bin_edges[begin:end-1]
bin_centers = midpoints(bin_edges)
bin_widths = diff(bin_edges)
# TODO: Prevent fit functions from returning negative PDF values
bin_ll(x, bw, k) = logpdf(Poisson(bw * f_fit(x)), k)
sum(Base.Broadcast.broadcasted(bin_ll, bin_centers, bin_widths, counts))
Expand Down

0 comments on commit 8dd6e84

Please sign in to comment.