Message Boards Message Boards

0
|
5886 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Generate a random Matrix with restrictions?

Posted 7 years ago

I need to randomly generate a 10x10 matrix with every element being a number between 1 and -1, I cannot figure out from the handbook how to place a limit on a randomly generated matrix. I would greatly appreciate an explanation or simply a direction to where I can find my answer. Thank you very much.

POSTED BY: Joseph Levano
2 Replies

Dear Joseph,

I'll assume you want a uniform distribution between -1 and 1. What about this?

RandomReal[{-1, 1}, {10, 10}]

Cheers,

Marco

PS: Sorry Yehuda, your answer only showed up after I posted. That seems to be a common problem. Sorry.

POSTED BY: Marco Thiel

I assume that you want the entries of the matrix to be uniformly distributed between -1 and 1 One option is to use RandomReal

RandomReal[{-1, 1}, {10, 10}]

For a more general approach (where you may use later with other distributions, use RandomVariate

RandomVariate[UniformDistribution[{-1, 1}], {10, 10}]

HTH

yehuda

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract