1
$\begingroup$

I get an error in mathematica when i try to get 10 samples of a MultinormalDistribution with:

sample = 10;
cov = {{0.0000606844, -0.000132364, -0.000149518}, {-0.000132364, 0.00103449,
   0.000833935}, {-0.000149518, 0.000833935, 0.00071455}};
mu= {0.00355655, -0.0517223, -0.026937};
dist = MultinormalDistribution[mu, cov]

Now by applying RandomVariate with a TruncatedDistribution between -1, 1 i want to generate 10 samples:

RandomVariate[
  TruncatedDistribution[
   ConstantArray[{-1, 1}, Length@mu], dist],
   sample] // Transpose

Instead i get the error Message

"The first argument of \
TruncatedDistribution[{{-1,1},{-1,1},{-1,1}},MultinormalDistribution[{\
0.00355655,-0.0517223,-0.026937},{{0.0000606844,-0.000132364,-0.\
000149518},<<1>>,{<<1>>}}]] is expected to be a valid truncation \
specification for the distribution \
MultinormalDistribution[{0.00355655,-0.0517223,-0.026937},<<1>>]."

Anyone knows what im doing wrong?

$\endgroup$
4
  • $\begingroup$ In the definition of "cov" is a brace missing. $\endgroup$ Commented Nov 3, 2021 at 19:28
  • $\begingroup$ Thanks for pointing it out, ive corrected the typo $\endgroup$
    – NeAr
    Commented Nov 3, 2021 at 19:30
  • $\begingroup$ So everything seems to work now but I think you probably want to remove the //Transpose. $\endgroup$
    – JimB
    Commented Nov 3, 2021 at 19:38
  • $\begingroup$ Similar to this $\endgroup$
    – Syed
    Commented Nov 4, 2021 at 5:32

1 Answer 1

2
$\begingroup$

I think the only problem is the in your Cover definition you are missing an opening brace for the two-dimensional list. When I fix that, it all runs fine.

cov = {{0.0000606844, -0.000132364, -0.000149518}, {-0.000132364, 
    0.00103449, 0.000833935}, {-0.000149518, 0.000833935, 0.00071455}};
$\endgroup$
3
  • $\begingroup$ Can you also try if it works for cov = {{0.000060684445410704884, -0.00013236382921520424, -0.00014951795735534325}, {-0.00013236382921519838, 0.0010344930628389817, 0.0008339346647649739}, {-0.00014951795735533924, 0.0008339346647649794, 0.0007145497794991608}} because for me it doesn't $\endgroup$
    – NeAr
    Commented Nov 3, 2021 at 19:48
  • $\begingroup$ Seems fine. result = {{0.00473948, -0.00541791, -0.0117304, 0.0012606, -0.00244112, -0.0131913, -0.00249456, -0.00812925, 0.00261845, -0.00296656}, {-0.0771857, -0.042381, -0.0869528, \ -0.0700794, 0.000998352, -0.0252476, -0.0346295, -0.0281032, 0.0125222, -0.0793516}, {-0.0461421, -0.0124056, -0.0348435, \ -0.0370063, 0.0168411, 0.00709373, -0.0101654, 0.000862649, 0.0173782, -0.0391015}} $\endgroup$
    – Michael
    Commented Nov 4, 2021 at 0:51
  • $\begingroup$ Hmm i still get the same error as explained in the beginning. This is really strange behaviour. I use Mathematica 12.0 $\endgroup$
    – NeAr
    Commented Nov 4, 2021 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.