RAND Function (LibreOffice Calc)

Math Beginner LibreOffice Calc Introduced in LibreOffice 3.0
math random simulation sampling stochastic numeric-processing

The RAND function in LibreOffice Calc returns a random decimal number between 0 and 1. It recalculates on every sheet update and is essential for simulations, sampling, testing, and randomized models.

Compatibility

What the RAND Function Does

  • Returns a random decimal between 0 and 1
  • Recalculates on every sheet update
  • Useful for simulations, sampling, and randomized models
  • Can be scaled to any numeric range
  • Works with other math functions for advanced stochastic modeling

It is designed to be simple, flexible, and universally compatible.

Syntax

RAND()

Arguments

  • None.
    RAND is a zero‑argument function.

Basic Examples

Generate a random decimal

=RAND()

Returns a value like 0.374829.

Generate a random number between 0 and 10

=RAND() * 10

Generate a random number between A1 and B1

=A1 + RAND() * (B1 - A1)

Generate a random percentage

=RAND()

Format as percent.

Advanced Examples

Random integer (manual method)

=INT(RAND() * 10)

Returns an integer from 0 to 9.

Random integer between two values

=INT(A1 + RAND() * (B1 - A1 + 1))

Equivalent to RANDBETWEEN(A1; B1).

Random Boolean (TRUE/FALSE)

=RAND() < 0.5

Random selection from a list

=INDEX(A1:A10; INT(RAND() * COUNTA(A1:A10)) + 1)

Randomly shuffle a list (helper column)

=RAND()

Sort by this column.

Monte Carlo simulation (single trial)

=IF(RAND() < 0.3; "Success"; "Fail")

Weighted random selection

=MATCH(RAND(); CUMULATIVE_RANGE)

Where CUMULATIVE_RANGE is a cumulative probability distribution.

Random normal distribution (Box–Muller)

=SQRT(-2 * LN(RAND())) * COS(2 * PI() * RAND())

Generates a normally distributed random value.

Common Errors and Fixes

RAND recalculates unexpectedly

Cause:

  • RAND updates on any sheet recalculation
  • Sorting, editing, or pressing F9 triggers new values

Fix:
Copy → Paste Special → Values to freeze results.

RAND returns 0 or 1 unexpectedly

Possible causes:

  • Formatting hides decimals
  • Very small values appear as 0
  • Very rare rounding edge cases

RAND appears not to change

Cause:

  • Automatic recalculation disabled
  • Sheet not recalculating

Fix:
Enable: Tools → Options → LibreOffice Calc → Calculate → AutoCalculate.

Best Practices

  • Use RAND for simulations and sampling
  • Use RANDBETWEEN for integer ranges
  • Freeze results with Paste Special → Values
  • Use RAND with INDEX for random selection
  • Use RAND with LN, PI, and COS for random distributions
RAND is the foundation of all stochastic modeling in Calc — from simple random picks to full Monte Carlo simulations.

Related Patterns and Alternatives

  • Use RANDBETWEEN for random integers
  • Use RAND() * (b - a) + a for custom ranges
  • Use INDEX + RAND for random selection
  • Use SORTBY (Excel) or manual sort with RAND for shuffling
  • Use NORMINV (Excel) or Box–Muller for normal distributions

By mastering RAND and its combinations with other math functions, you can build powerful, flexible randomization and simulation models in LibreOffice Calc.

Copyright 2026. All rights reserved.