Documentation/Calc Functions/RAND
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Function name:
RAND
Category:
Mathematical
Summary:
Generates a uniformly distributed random number in the range 0 (inclusive) to 1 (exclusive).
Syntax:
RAND()
Returns:
Returns a real number in the range [0, 1).
Arguments:
None.
Additional details:
- RAND is a volatile function that produces a new random number each time Calc recalculates. This means that Calc will update the value returned by RAND when any cell is updated by selecting ▸ ▸ or pressing F9, or on any input event.
- Use the RAND.NV function for a non-volatile equivalent.
- To generate random numbers that never recalculate, either:
- Copy cells containing
=RAND()
, and use ▸ (with All and Formulas deselected and Numbers selected). - Use ▸ ▸ to fill a selected cell range with random numbers, generated in accordance with the flexible settings available through the Random Number Generator dialog.
- Copy cells containing
- To generate numbers in a range other than [0, 1), either:
- Scale the value returned by RAND to a new range using a formula of the form
=(RAND()*(b-a))+a
to generate a number in the range [a, b). For example, the formula=(RAND()*20)-10
would generate random numbers in the range [-10, 10). - Use the RANDBETWEEN function or its non-volatile equivalent RANDBETWEEN.NV.
- Scale the value returned by RAND to a new range using a formula of the form
Examples:
Formula | Description | Returns |
---|---|---|
=RAND() |
Generate a random number r in the range 0 ≤ r < 1. The returned value will change whenever Calc recalculates. |
0.41196744494765 |
Related LibreOffice functions:
ODF standard:
Related (or similar) Excel functions:
RAND