Message Boards Message Boards

0
|
1776 Views
|
4 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Reuse of result from RandomInteger

Posted 3 years ago

I would like to reuse the data received through RandomInteger, without writing the data again. Is it possible?

POSTED BY: Åsa Wesshagen
4 Replies
Posted 3 years ago

Does the code below work for you?

SeedRandom[4]
vector = RandomInteger[{-10, 10}, 3]

Graphics3D[Arrow[{{0, 0, 0}, vector}]]
POSTED BY: Hans Milton
Posted 3 years ago

Hans, I am really happy with the result! Thank you again!!! /Åsa

POSTED BY: Åsa Wesshagen
Posted 3 years ago

Thanks a lot, Hans!!

I have an assignment where I am supposed to calculate various things concerning a vector. First I am to find three randomly chosen numbers that define my vector, using RandomInteger. After that I am to save the vector values (a, b, c) using "new commandos", (in order for me not to randomly chose another set of numbers). (Quite obviously, I am not supposted to type in the three values again, even if that seems like an easy thing to do). Followingly, I used the SeedRandom commando, that you so kindly suggested. Nevertheless, as I continue to do my assignment, I do not manage to make Mathematica call for my vectors' values when using other commandos such as: Norm[] Dot[] ArcCos[] Graphics3D[{Arrow[{{0, 0, 0}, {a, b, c}}], Arrow[{{0, 0, 0}, {32, -140, -55}}]}]

Do you have any idea of what I might be doing wrong? /Åsa

POSTED BY: Åsa Wesshagen
Posted 3 years ago

Try SeedRandom. From the RandomInteger documentation:

enter image description here

POSTED BY: Hans Milton
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