Coveralls logob
Coveralls logo
  • Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

theogf / KLDivergences.jl / 1045860141

19 Jul 2021 - 16:14 coverage: 60.0% (-17.8%) from 77.778%
1045860141

Pull #8

github

GitHub
Merge 226539b8a into cdc031c57
Pull Request #8: Loosen MvNormal and add StatsBase inheritance

1 of 7 new or added lines in 2 files covered. (14.29%)

12 of 20 relevant lines covered (60.0%)

496221.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.57
/src/multivariate.jl
1
function KL(p::AbstractMvNormal, q::AbstractMvNormal)
NEW
2
    length(p) == length(q) || 
!
3
        throw(DimensionMismatch("Distributions p and q have different dimensions $(length(p)) and $(length(q))"))
NEW
4
    Σp = cov(p)
!
NEW
5
    Σq = cov(q)
!
NEW
6
    Δμ = mean(p) - mean(q)
!
NEW
7
    0.5 * (tr(Σq \ Σp) + dot(Δμ / Σq, Δμ) - length(p) + logdet(Σq) - logdet(Σp))
!
8
end
9

10
function KL(p::MvNormal, q::MvNormal)
11
    length(p) == length(q) || 
24×
12
        throw(DimensionMismatch("Distributions p and q have different dimensions $(length(p)) and $(length(q))"))
13
    0.5 * (tr(q.Σ \ p.Σ) + invquad(q.Σ, mean(p) - mean(q)) - length(p) + logdet(q.Σ) - logdet(p.Σ))
18×
14
end
Troubleshooting · Open an Issue · Sales · Support · ENTERPRISE · CAREERS · STATUS
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2023 Coveralls, Inc