[julia-users] Multivariate Normal versus Multivariate Normal Canon in Distributions package

2014-08-23 Thread asim


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


Re: [julia-users] Multivariate Normal versus Multivariate Normal Canon in Distributions package

2014-08-24 Thread John Myles White
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  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



Re: [julia-users] Multivariate Normal versus Multivariate Normal Canon in Distributions package

2014-08-25 Thread John Myles White
This looks like a failure to find functions from NumericFuns.

What versions of Julia and stats packages are you using?

 -- John

On Aug 25, 2014, at 9:03 AM, asim  wrote:

> 



Re: [julia-users] Multivariate Normal versus Multivariate Normal Canon in Distributions package

2014-08-27 Thread John Myles White
Hi Asim,

Can you open an issue on GitHub?

-- John

On Aug 26, 2014, at 2:46 PM, asim  wrote:

> I am using Julia version 0.3 and its associated packages. These packages are 
> being used after a Pkg.update() command. 
> 
> I have attached another notebook that details the problems. First, the random 
> draws for the mvNormalCanon version of the multivariate normal do not appear 
> to be correct as one cannot obtain the correct covariance matrix from the 
> draws. 
> 
> Second, the rand function also seems to have an additional problem in that it 
> tries to use some badd! function when generating multiple draws from the 
> distribution, and this function is not found. I am not sure where this 
> function is, either. 
> 
> Thanks
> 
> Asim 
> 
> 
> 
> On Monday, August 25, 2014 6:14:40 PM UTC-4, John Myles White wrote:
> This looks like a failure to find functions from NumericFuns. 
> 
> What versions of Julia and stats packages are you using? 
> 
>  -- John 
> 
> On Aug 25, 2014, at 9:03 AM, asim  wrote: 
> 
> >  
> 
>