Skip to main content
2 of 4
edited tags

Is there an equivalent to (the non-existent feature) RandomReal[{range1,range2,...,rangen},{m,n}]

I know that you can generate an $m\times n$ matrix of random numbers by RandomReal[range, {m, n}], where e.g. range = {0, 1}.

Is there a way to generate an $m\times n$ matrix of random numbers and have each column entry be drawn from a different range?

My question is, if there is something analogous to RandomReal[{range1,range2,...,rangen},{m,n}] (which obviously does not evaluate because it is not supported).

My current solution to this problem is using Map; i.e.

 Transpose[
   Map[
     RandomReal[#,m]&,
     {range1,range2,...,rangen}
   ]
  ]

where m is the desired number of $n$-tuples of random numbers from $n$ different ranges that I need.

Is there a better alternative to this?

user42582
  • 4.2k
  • 1
  • 11
  • 32