Group Abstract Group Abstract

Message Boards Message Boards

array containing random complex numbers

Posted 11 years ago

Hello again, I am asking for your help to generate an array of 18 x 18 containing random complex numbers with a normal distribution,, I have made the next:

datos = Partition[Riffle[RandomVariate[NormalDistribution[], 18], 
    RandomVariate[NormalDistribution[], 18]], 2];

Apply[Plus, {#[[1]], #[[2]]*I} & /@ datos, 1] // MatrixForm

but don't know what steps to follow to get an array of 18 columns by 18 rows,

i hope that someone has a solution for this problem.

POSTED BY: Luis Ledesma
4 Replies

It appears that you generated just one row of the desired 18 x 18 matrix. Why not generate a row of 18*18=324 complex numbers and then partition the result into a matrix? Something like this slight modification to your code should work.

datos = Partition[
   Riffle[RandomVariate[NormalDistribution[], 18^2], 
    RandomVariate[NormalDistribution[], 18^2]], 2];

Partition[Apply[Plus, {#[[1]], #[[2]]*I} & /@ datos, 1], 
  18] // MatrixForm
POSTED BY: Gerard Kopcsay
Posted 11 years ago

Many thanks ,I was with your solution that I have proposed, I believe it is useful for what I am going to use it. Thanks again for helping me with this problem.

Luis Ledesma.

POSTED BY: Luis Ledesma

You can probably simplify a bit. For example, since real and imaginary parts are taken from the same normal distribution, you could generate all the randoms at once, and then partition to make the next step a bit simpler. Something like the following might be a bit faster.

datos = Partition[RandomVariate[NormalDistribution[], 2 18^2], 18^2];

Partition[datos[[1]] + I datos[[2]], 18] // MatrixForm
POSTED BY: Gerard Kopcsay
Posted 11 years ago
POSTED BY: Luis Ledesma
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard