Skip to content

Commit

Permalink
Merge pull request #28 from tdixon97/main
Browse files Browse the repository at this point in the history
[bug-fix] fixes double loop in likelihood
  • Loading branch information
sofia-calgaro authored Sep 9, 2024
2 parents 64607c1 + 1596fec commit 076e1e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
FilePathsBase = "48062228-2e41-5def-b9a4-89aafe57970f"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
Expand Down
23 changes: 11 additions & 12 deletions src/likelihood.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,20 @@ free parameters: signal (S), background (B), energy bias (biask) and resolution
end

ll_value += logpdf(Poisson(λ), length(events_k))

for i in events_k
for evt_energy in events_k

term1 = model_b_k / deltaE # background

for evt_energy in events_k
term1 = model_b_k / deltaE # background

if (stat_only==true)
term2 = model_s_k * pdf(Normal(Qbb + part_k.bias, part_k.fwhm/2.355), evt_energy) # signal (fixed nuisance)
else
term2 = model_s_k * pdf(Normal(Qbb + p.𝛥[idx_part_with_events], p.σ[idx_part_with_events]), evt_energy) # signal (free nuisance)
end
ll_value += log( (term1 + term2)+eps(term1+term2)) - log(model_tot_k+eps(model_tot_k))
if (stat_only==true)
term2 = model_s_k * pdf(Normal(Qbb + part_k.bias, part_k.fwhm/2.355), evt_energy) # signal (fixed nuisance)
else
term2 = model_s_k * pdf(Normal(Qbb + p.𝛥[idx_part_with_events], p.σ[idx_part_with_events]), evt_energy) # signal (free nuisance)
end

ll_value += log( (term1 + term2)+eps(term1+term2)) - log(model_tot_k+eps(model_tot_k))
end



return ll_value
end
Expand All @@ -83,7 +82,7 @@ Returns:
--------
DensityInterface.logfuncdensity - the likelihood function
"""

@debug part_event_index
return DensityInterface.logfuncdensity( function(p)
total_ll = 0.0

Expand Down

0 comments on commit 076e1e5

Please sign in to comment.