Google spreadsheet - How to set a seed for random number generation

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

From what I understand, there is no built-in function in Google Sheets that allows you to set a seed for RAND() or RANDBETWEEN().

My goal is to create a list of psuedo-random integers, within a range, using a function that will produce different (though, not necessarily unique) values based on:

    • Which cell is running the function
    • And the value in a second cell that contains a seed of my choosing

I need it to produce the same value every time the function is run in a particular cell, with a particular seed.

What is the simplest way to achieve this, so that someone who isn t me and has no programming knowledge can easily use the formula in other cells, as they need to?

Answers

Short answer

Use VLOOKUP and ADDRESS

Explation

Create a simple table with two columns, one for a compound key made from the cell address and the "seed" the other for the "seudo-random integers" (SRI)

Simple table

Sheet name: Table

Sheet content (for illustrative purposes):

 |  A   |  B   | 
1|key   |  SRI |
2|A1-1  |    1 |
3|A1-2  |   77 |

Formula

=VLOOKUP(ADDRESS(ROW(),COLUMN(),4,FALSE)&"-1",Table!A2:B,2,0)

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/40498087/how-to-set-a-seed-for-random-number-generation

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils