Can you clarify a bit what you mean by “same result”? It would also be great to see a simpler example that doesn’t involve the Bayesian updating steps, which hopefully aren’t essential to hitting an error.
— John On Aug 23, 2014, at 4:33 PM, asim <[email protected]> wrote: > > > I am trying to use the multivariate normal canonical form to draw random > numbers. According to my understanding, the following two functions should > give the same result over a large number of draws, but I am getting different > results. What am I doing wrong. > > function ablRegCoeffPostDraw(xtx::Array{Float64, 2}, xty::Array{Float64, 1}, > errorVariance::Float64, priorMean::Array{Float64, 1}, > priorPrec::Array{Float64, 2}) > > postPrec=priorPrec+xtx/errorVariance > > postMean=priorPrec*priorMean+xty/errorVariance > > postMean=postPrec\postMean > > rand(MvNormal(postMean, inv(postPrec))) > > end > > function ablRegCoeffPostDraw1(xtx::Array{Float64, 2}, xty::Array{Float64, 1}, > errorVariance::Float64, priorMean::Array{Float64, 1}, > priorPrec::Array{Float64, 2}) > > postPrec=priorPrec+xtx/errorVariance > > postMean=priorPrec*priorMean+xty/errorVariance > > postMean=postPrec\postMean > > potential=postPrec*postMean > > rand(MvNormalCanon(potential, postPrec)) > > end
