Multivariate Gaussian Object creation

I am working on a project that involves pulling toy data from a multivariate gaussian and am having some trouble getting the RooMultiVarGaussian object to work, I currently have this:

    RooMultiVarGaussian mvg("mvg", "mvg", fit, mu, cov);

    RooDataSet* data = mvg.generate(fit,1000);

And I get an error:
error: no matching constructor for initialization of ‘RooMultiVarGaussian’

RooMultiVarGaussian mvg(“mvg”, “mvg”, fit, mu, cov);

For reference, fit is a RooArgList and so is mu each with 26 elements, and cov is a TMatrixD object (in the class reference it says that it should be TMatrixDSym but I’m not sure how to convert or if that is even the issue.

Thank you!

Dear @DTMsurf ,

cov is a TMatrixD object (in the class reference it says that it should be TMatrixDSym but I’m not sure how to convert or if that is even the issue.

This is definitely the issue. I hope @moneta or @jonas can help you out with this.

Cheers,
Vincenzo

Hi! Fortunately it’s easy to convert a TMatrixD to a TMatrixDSym, here is an example:

   TMatrixD cov1{2, 2};
   cov1(0, 0) = 1.0;
   cov1(0, 1) = 0.2;
   cov1(1, 0) = 0.2;
   cov1(1, 1) = 1.0;

   TMatrixDSym cov{cov1.GetNrows()}; // symmetric matrix has nrows = ncols
   cov.SetSub(0, cov1); // fill cov with the values from cov1

   // check check check
   cov1.Print();
   cov.Print();

Just make sure that your original covariance matrix is symmetric (TMatrixDSym::SetSub() will print an error otherwise).

I hope this helps!
Jonas

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.