views:

357

answers:

2

Hi,

what is the best approach to generate random samples from bivariate normal and student T distributions? In both cases sigma is one, mean 0 - so the only parameter I am really interested in is correlation (and degrees of freedom for student t). I need to have the solution in C++, so I can't unfortunately use already implemented functions from MatLab or Mathematica.

+3  A: 

You should take a look at the Boost libraries random distributions - see http://www.boost.org/doc/libs/1_41_0/libs/random/random-distributions.html. I've found them very easy to use, once you wrap your head around their basic concepts. Unfortunately, I don't know enough about statistics to tell you whether they will exactly meet your needs.

anon
They don't seem to implement any of the distributions I am after :(
Grzenio
+4  A: 

You can use the GNU GSL libraries. See here for Bivariate normal:

http://www.gnu.org/software/gsl/manual/html_node/The-Bivariate-Gaussian-Distribution.html

and Student's t-distribution here:

http://www.gnu.org/software/gsl/manual/html_node/The-t_002ddistribution.html

They are straight forward to use.

dangerstat
Cool, they have the bivariate Gaussian, but the Student T seems to be only univariate :(
Grzenio
You can simulate from a multivariate t distribution using the representation of the multivariate t in terms of a multivariate normal and a chi2 distribution. GSL has both MVN and Chi2, so you are set. See the first paragraph: http://en.wikipedia.org/wiki/Multivariate_Student_distribution.
Tristan