Skip to main content
edited tags
Link
edited title
Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

Is there an equivalent to (the non-existent feature) RandomReal[{range1,range2,...,rangen},{m,n}] Generate random matrix where the entries in each column are drawn from a different range

Tweeted twitter.com/StackMma/status/925707791012069377
edited tags
Source Link

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

Is there a way to generate an $m$x$n$$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 ie; i.e.

 Transpose[
   Map[
     RadomReal[#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?

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

Is there a way to generate an $m$x$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 ie

 Transpose[
   Map[
     RadomReal[#,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?

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?

Source Link
user42582
  • 4.2k
  • 1
  • 11
  • 32
Loading