I answered my question by implementing this method:
https://en.wikipedia.org/wiki/Multivariate_normal_distribution#Drawing_values_from_the_distribution

NB. drawing a random vector from a multivariate normal distribution
require '~addons/stats/distribs/normal.ijs'
load 'math/lapack'
load 'math/lapack/potrf' NB. Cholesky decomposition

mp=: +/ . *
chol=: potrf_jlapack_
isv=: rnorm01_pdistribs_ NB. independent standard variates

NB. For example we consider a 2d gaussian
mu=: 0 4 
d=: #mu
sg=: d d $ 3 0 0 0.5
a=: chol sg

NB. To draw a random vector, I can do:
x=: mu + a mp isv d

Best wishes,
Pierre-Edouard

On Wed, Jan 11, 2017 at 05:12:24PM +0100, Pierre-Edouard Portier wrote:
> Dear all,
> 
> How would you draw samples from a multivariate gaussian distribution?
> E.g. a gaussian with mean 'mu=:0 4' and covariance 'sg=:2 2 $ 3 0 0 0.5'
> 
> Best wishes,
> Pierre-Edouard
> -- 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to