I want to make n random draws from a Multivariate Normal distribution, then divide each element in each of the random draws by the norm of the random draw. Mathematically, I want to obtain \mathbf{y}_i=\mathbf{x}_i/||\mathbf{x}_i|| for i=1,\dots,n, where \mathbf{x}_i\sim\text{N}(\boldsymbol{\mu},\mathbf{V}).
Here is my current code:
X = rand(MvNormal(mu, Hermitian(V)), n)'
Y = X ./ sqrt.(sum(X.^2, dims=2))
This is fast, but I’m hoping to make this even quicker. I am using this code in an iterative algorithm, where this is called hundreds of times per iteration, so any computational savings will add up and help! However, I’m doubtful that it can be made quicker as I have yet to find a way to do so. This discourse is my last hope!
Thank you for your time.