rand

This page explains how to use the rand function in APL.

Use the rand function in APL to generate pseudo-random numbers. This function is useful when you want to introduce randomness into your queries. For example, to sample a subset of data, generate test data, or simulate probabilistic scenarios.

Usage

Syntax

rand()
rand(range)

Parameters

NameTypeDescription
rangeintegerOptional: A positive integer that specifies the upper exclusive limit of the range where you want to generate pseudo-random integers. The lower inclusive limit is 0.

Returns

Without range: A real number in the range between 0 (inclusive) and 1 (exclusive). Each call returns a pseudo-random float. With range: An integer in the range between 0 (inclusive) and range (exclusive).

Example

Query

print random = rand()

Run in Playground

Output

_timerandom
2024-07-10T14:32:00Z0.6324890121902683

Other query languages