You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import AdvancedMH, LogDensityProblems, Distributions
struct TheNormalLogDensity{M}
A::Mend# can do gradient
LogDensityProblems.capabilities(::Type{<:TheNormalLogDensity}) = LogDensityProblems.LogDensityOrder{1}()
LogDensityProblems.dimension(d::TheNormalLogDensity) =size(d.A, 1)
LogDensityProblems.logdensity(d::TheNormalLogDensity, x) =-x'* d.A * x /2function LogDensityProblems.logdensity_and_gradient(d::TheNormalLogDensity, x)
return-x'* d.A * x /2, -d.A * x
end
Σ = [1.50.35; 0.351.0]
σ² =0.5
spl = AdvancedMH.MALA(g -> Distributions.MvNormal((σ² /2) .* g, σ² * I))
#spl = RWMH(MvNormal(zeros(2), I))
chain = AdvancedMH.sample(TheNormalLogDensity(inv(Σ)), spl, 500000; initial_params=ones(2))
data =stack([c.params for c = chain])
cov(data, dims=2)
Someone pointed out that MALA results in samples that have a wrong covariance.
It is not a mixing/variance issue since I'm hitting an acceptance rate of 0.57.
For the above example, I get:
I didn't have the time to look into too much detail, but it seems that RWMH returns the correct covariance, while only MALA does not. For instance, RWMH yields:
* fix for issue #95
* fixed failing tests
* remove usage of stack and stop logging so much progress
* removed more progress logging in test suite
* removed more progress logging
* bump patch version
Someone pointed out that MALA results in samples that have a wrong covariance.
It is not a mixing/variance issue since I'm hitting an acceptance rate of
0.57
.For the above example, I get:
I didn't have the time to look into too much detail, but it seems that
RWMH
returns the correct covariance, while onlyMALA
does not. For instance,RWMH
yields:The text was updated successfully, but these errors were encountered: