0
|
11984 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
GROUPS:

# array containing random complex numbers

Posted 10 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.
4 Replies
Sort By:
Posted 10 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 10 years ago
 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 10 years ago
 A lot thanks Gerard Kopcsay, I have tested your modification and works properly, I'm going to use larger arrays of 1000 x 1000 do you think that this code will be efficient for that type of arrays or should find out if there is some other way to do the same.Luis
Posted 10 years ago
 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