File tree 3 files changed +11
-2
lines changed
3 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ DistributionsAD = "ced4e74d-a319-5a8a-b0ac-84af2272839c"
13
13
DocStringExtensions = " ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
14
14
FillArrays = " 1a297f60-69ca-5386-bcde-b61e274b549b"
15
15
HeterogeneousComputing = " 2182be2a-124f-4a91-8389-f06db5907a21"
16
+ IrrationalConstants = " 92d709cd-6900-40b7-9082-c6be49f344b6"
16
17
IterativeSolvers = " 42fd0dbc-a981-5370-80f2-aaf504508153"
17
18
LineSearches = " d3d80556-e9d4-5f37-9878-2ab0fcc64255"
18
19
LinearAlgebra = " 37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -47,6 +48,7 @@ DistributionsAD = "0.6"
47
48
DocStringExtensions = " 0.8, 0.9"
48
49
FillArrays = " 1.1.1"
49
50
HeterogeneousComputing = " 0.2"
51
+ IrrationalConstants = " 0.2.2"
50
52
IterativeSolvers = " 0.8, 0.9"
51
53
LineSearches = " 7"
52
54
LinearAlgebra = " 1"
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ using Distributions
22
22
using DistributionsAD
23
23
using FillArrays
24
24
using HeterogeneousComputing: GenContext, allocate_array
25
+ using IrrationalConstants: log2π
25
26
using LineSearches
26
27
using LinearMaps
27
28
using Parameters
Original file line number Diff line number Diff line change 1
1
# This file is a part of MGVI.jl, licensed under the MIT License (MIT).
2
2
3
+ function _mv_normal_logdensity (x:: AbstractVector{<:Real} )
4
+ T = eltype (x)
5
+ r = - dot (x, x)/ 2 - T (length (x)) * T (log2π/ 2 )
6
+ return r
7
+ end
8
+
3
9
function posterior_loglike (model, p, data)
4
10
likelihood_value = logdensityof (model (p), data)
5
- # normal prior, leaving out `+ length(p)*log2π/2` normalization constant
6
- prior_density = - dot (p, p) / 2
11
+ # standard multivariate normal prior:
12
+ prior_density = _mv_normal_logdensity (p)
7
13
return likelihood_value + prior_density
8
14
end
9
15
You can’t perform that action at this time.
0 commit comments