I am using the programming language Lua which does not have any built-in function for drawing samples from a multivariate Gaussian distribution. So I wonder, how can one implement a function that does the sampling for a multivariate Gaussian distribution? Note that I do have access to a function which can draw samples from a single-variable Gaussian distribution. Can I somehow use that function to draw samples for the multivariate case given a desired covariance matrix?
Also, if I'm not mistaken, I remember I read somewhere that one can draw samples from a single-variable Gaussian distribution as follow:
$\text{sample } = \mu + \sigma^2 \epsilon$
where $\mu$ is a mean, $\sigma^2$ is a variance and $\epsilon \sim U(0,1)$. Therefore, a generalization of the above equation for a multivariate Gaussian distribution is to have mean and [diagonal] covariance matrix. However, if not sure if this equation is valid by itself and whether it gives valid samples for a non-diagonal covariance matrix.
So I wonder, can you guys give me some insights on how one should go about generating samples for a multivariate Gaussian distribution given a desired non0diagonal covariance matrix and without having having access to a built-in function in a programming language? Also, I would appreciate your help to verify/prove the equation I wrote above.