Skip to content

Commit

Permalink
Merge branch 'wishart' of github.com:ppegolo/sportran into wishart
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Pegolo committed Sep 18, 2024
2 parents 8dcb5e2 + 0e07793 commit 2de0b26
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions sportran/md/maxlike.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,24 @@ def log_likelihood_wishart(

trinvV_X = opt_einsum.contract("wab,wba->w", invV, X)

coeff_detV = -n
coeff_detX = n - p - 1
# coeff_detV = -n
# coeff_detX = n - p - 1
logG = multigammaln(0.5 * n, p)

log_pdf = (
coeff_detV * np.log(detV + eps) + coeff_detX * np.log(detX + eps) - trinvV_X
0.5
* (
(n - p - 1) * np.log(detX)
- trinvV_X
- n * np.log(detV)
- n * p * np.log(2)
)
- logG
)

# log_pdf = (
# 0.5*(coeff_detV*np.log(detV + eps) + coeff_detX*np.log(detX + eps) - trinvV_X) - logG
# )
tot = -np.sum(log_pdf)
return tot

Expand Down Expand Up @@ -379,9 +391,10 @@ def log_likelihood_complex_wishart(

trinvS_X = opt_einsum.contract("wab,wba->w", invS, X).real

log_pdf = (n - p) * logdetX - trinvS_X - n * logdetS
# coeff_detV = -n
# coeff_detX = n-p-1
log_pdf = (n - p) * logdetX - trinvS_X - n * logdetS

# log_pdf = coeff_detV * np.log(detV) + coeff_detX * np.log(detX) - trinvV_X
# # print(-np.sum(log_pdf))
return -np.sum(log_pdf)
Expand Down

0 comments on commit 2de0b26

Please sign in to comment.