random

random()

random(max)

random(min, max)

random(size)

random(size, max)

random(size, min, max)

Try it yourself:


random(): Generating Random Values

random() generates pseudo-random numeric values, commonly in a specified range. It is useful for simulations, sampling, test data, and randomized visual effects.

Randomness and reproducibility

A generated value is not a guarantee of fairness or cryptographic security. For simulation results, record the seed or generated inputs when reproducibility matters. Use randomInt() when outcomes must be integers, and round() only for display rather than to simulate a uniform integer.

Validate lower and upper bounds, especially when bounds may be reversed or equal. Combine random values with min() and max() for clamping only when that distributional effect is intentional.

Try Random in Calcul.io

Start with one of the editable examples above, then replace its arguments with your own values. Keeping the function on a separate calculator line makes the input and result easy to compare. For a longer workflow, assign the result to a variable or reference that line in the next expression.

Check the shown signature before adding optional arguments, and use the related-function links to compare operations with similar purposes.

All functions