Python analog of mvrnorm's empirical setting when generating a multivariate distribution?
Question: So in `R`'s `MASS` package there is a function called `mvrnorm` for generating
multivariate distributions. It has an argument called `empirical` which, when
set to to TRUE, mu (means) and sigma (covariance matrix) specifiy the
emperical, not the population mean and covariance matrix.

In short, when you pull out samples the means and variances are very similar
to what was prescribed.

Is there anything similar in python? I have been unable to find anything like
this in numpy, for example.


Answer: Solution:

    
    
    import numpy as np
    import rpy2
    import rpy2.robjects as robjects
    from rpy2.robjects.packages import importr
    MASS = importr('MASS')                       # Must use R: install.packages('MASS')
    r = robjects.r
    
    np.matrix(MASS.mvrnorm(n = 10, mu = r.c(0,0), Sigma = r.diag(2), empirical = True))
    

[This helped.](http://stackoverflow.com/questions/11163472/fitdistr-in-rpy2)

