Skip to content

Commit

Permalink
Faster evaluation of log likelihood
Browse files Browse the repository at this point in the history
  • Loading branch information
mbustama authored Nov 15, 2019
1 parent d32a174 commit 447e4b3
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions dev-likelihood-sl/full_likelihood.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,21 @@ def Log_Likelihood(double gamma, double log10_g, double log10_M,
# Call Initialize_Interpolator_Astrophysical_PDF and
# Initialize_Atmospheric_PDFs (once) before calling this function

cdef double fl_sh
cdef double fl_tr
# cdef double fl_sh
# cdef double fl_tr
cdef double log_fl_sh
cdef double log_fl_tr
cdef double log_likelihood
# cdef double tt
cdef int i

# Showers
fl_sh = multiply_manual( \
[Partial_Likelihood_Showers(i, gamma, log10_g, log10_M, N_a,
N_conv, N_pr, N_mu, interp_astro_pdf_sh, pdf_atm_conv_sh,
pdf_atm_pr_sh, verbose=verbose) for i in range(num_ic_sh)])
log_fl_sh = sum([log(Partial_Likelihood_Showers(i, gamma, log10_g, log10_M,
N_a, N_conv, N_pr, N_mu, interp_astro_pdf_sh, pdf_atm_conv_sh,
pdf_atm_pr_sh, verbose=verbose)) for i in range(num_ic_sh)])
# fl_sh = multiply_manual( \
# [Partial_Likelihood_Showers(i, gamma, log10_g, log10_M, N_a,
# N_conv, N_pr, N_mu, interp_astro_pdf_sh, pdf_atm_conv_sh,
# pdf_atm_pr_sh, verbose=verbose) for i in range(num_ic_sh)])
# fl_sh = reduce(lambda x, y: x*y, \
# [Partial_Likelihood_Showers(i, gamma, log10_g, log10_M, N_a,
# N_conv, N_pr, N_mu, interp_astro_pdf_sh, pdf_atm_conv_sh,
Expand All @@ -107,11 +111,15 @@ def Log_Likelihood(double gamma, double log10_g, double log10_M,
# pdf_atm_pr_sh, verbose=verbose) for i in range(num_ic_sh)])

# Tracks
fl_tr = multiply_manual( \
[Partial_Likelihood_Tracks(i, gamma, log10_g, log10_M, N_a,
N_conv, N_pr, N_mu, interp_astro_pdf_tr, pdf_atm_conv_tr,
pdf_atm_pr_tr, pdf_atm_muon_tr, verbose=verbose) \
log_fl_tr = sum([log(Partial_Likelihood_Tracks(i, gamma, log10_g, log10_M,
N_a, N_conv, N_pr, N_mu, interp_astro_pdf_tr, pdf_atm_conv_tr,
pdf_atm_pr_tr, pdf_atm_muon_tr, verbose=verbose)) \
for i in range(num_ic_tr)])
# fl_tr = multiply_manual( \
# [Partial_Likelihood_Tracks(i, gamma, log10_g, log10_M, N_a,
# N_conv, N_pr, N_mu, interp_astro_pdf_tr, pdf_atm_conv_tr,
# pdf_atm_pr_tr, pdf_atm_muon_tr, verbose=verbose) \
# for i in range(num_ic_tr)])
# fl_tr = reduce(lambda x, y: x*y, \
# [Partial_Likelihood_Tracks(i, gamma, log10_g, log10_M, N_a,
# N_conv, N_pr, N_mu, interp_astro_pdf_tr, pdf_atm_conv_tr,
Expand All @@ -123,10 +131,9 @@ def Log_Likelihood(double gamma, double log10_g, double log10_M,
# for i in range(num_ic_tr)])


log_likelihood = log(exp(-N_a-N_conv-N_pr-N_mu)*fl_sh*fl_tr) + 400.0 #-ll_den
log_likelihood = -N_a-N_conv-N_pr-N_mu+log_fl_sh+log_fl_tr #+ 700.0 #-ll_den
# log_likelihood = log(exp(-N_a-N_conv-N_pr-N_mu)*fl_sh*fl_tr) + 700.0 #-ll_den

# tt = N_a+N_conv+N_pr+N_mu-80.0
# log_likelihood = log(exp(-N_a-N_conv-N_pr-N_mu)*fl_sh*fl_tr/tt)-ll_den

return log_likelihood

Expand Down

0 comments on commit 447e4b3

Please sign in to comment.