Page 1 of 1

Generate 3 random numbers between 1 to 600 always the same

PostPosted: Wed Nov 27, 2019 8:12 pm
by enigmer
Hi, it's the first time I ask something here, I hope someone can help me ;)

I'll try to explain the problem.
I want to extract randomly 3 different numbers between 1 to 600 and I want that every time I do this extraction again, the 3 numers are the same.
I Know there are functions in some programs like c++ that using a pattern, for example a date, or a number, or a word, can do this thing.
Is it possible in OpenOffice Calc?

Note that I want to use a random function to be impartial in this extraction and I need every time the same numbers to show to every person that using a certain pattern or function I obtain the same 3 numbers.

Thanks for every suggest!

Re: generate 3 random numbers between 1 to 600 always the sa

PostPosted: Wed Nov 27, 2019 8:41 pm
by John_Ha
Calc uses seeds to ensure generated random numbers are as random as possible and repeating the action will give different numbers. Also note that the generated numbers change every time any change is made to the sheet or any calculation is done

The file gives the idea. A random number generated by Calc is always 0 < random_number < 1, so multiply by 599 and add 1, and round, to ensure the answer is always 1 < number < 600 .

1. Do it once.
2. Store the results.

Try 87, 493, 154.

See the Calc Tutorials and Calc Manual.

Re: Generate 3 random numbers between 1 to 600 always the sa

PostPosted: Wed Nov 27, 2019 10:16 pm
by RusselB
Alternatively you could use the RANDBETWEEN function, where you specify the upper and lower limits.

Re: Generate 3 random numbers between 1 to 600 always the sa

PostPosted: Wed Nov 27, 2019 10:16 pm
by enigmer
Thanks for the replay.
I understand that I cannot do what I want because I need that extracted numbers are always the same, like using rnd() function that without resetting its index give always same results.

Anyway, thanks again.

Re: Generate 3 random numbers between 1 to 600 always the sa

PostPosted: Wed Nov 27, 2019 10:42 pm
by RoryOF
On first call to the random number generator you could note that it is first call (using Global variable) and store the three generated numbers, together with any parameters to indicate the user to whom those numbers are assigned (again: Global variables). On second call, from that user, the random number generator is bypassed and the stored numbers are returned.

If each user is to be assigned three initially random numbers specific to that user, this process is repeated for the first and subsequent calls from each user, again using Global Variables (or writing them to an array stored as a Global variable, if that is permissible - not checked)

If the numbers have to be preserved across sessions, instead of using Global variables, which will be set afresh with each running of the program, the results could be stored to a small plain text file and retrieved from that.

Re: Generate 3 random numbers between 1 to 600 always the sa

PostPosted: Wed Nov 27, 2019 11:56 pm
by MrProgrammer
Hi, and welcome to the forum.

enigmer wrote:I want to extract randomly 3 different numbers between 1 to 600 …
I will guess that you mean different integers. If you mean real numbers, not integers, three cells with =1+599*RAND() will be different. To prevent them from changing, select these cells, Edit → Copy, Edit → Paste Special → Paste All → Numbers → OK.

John_Ha wrote:Try 87, 493, 154.
This is the simplest method. Just pick three integers. Those are as good as any. Need more? Random Integer Set Generator

enigmer wrote:I want to extract randomly 3 different numbers between 1 to 600 …
[Tutorial] Randomization in Calc technique C. Creating uniformly-distributed unique random integers between specified minimum and maximum values

enigmer wrote:I want that every time I do this extraction again, the 3 numers are the same.
Neither RAND() not RANDBETWEEN() provides a way to specify the seed for the random number algorithm, however for people who use Linux or Windoze, the Mersenne Twister Random Number Generator Add-In says one can specify the seed.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know

Re: Generate 3 random numbers between 1 to 600 always the sa

PostPosted: Thu Nov 28, 2019 7:16 pm
by enigmer
Thanks for all suggestions!
I'll try tomorrow :)