uniform(number, number)

uniform(number, number), function

def pure uniform(min: number, max: number): zedfunc

Returns the function $f: k \mapsto \bold 1 (k \in [\text{min},\text{max}])$, that maps $k$ to $1$ if $k \in [\text{min},\text{max}]$ and $0$ otherwise.
The arguments min and max must be integers such that min $\leq$ max or the function fails.

Example

show scalar "" a1b2 with uniform(3, 5)

Errors

Calling uniform with a non-integer argument will fail and return one of the following errors:

‘uniform(min,max)’ is rounding fractional numbers in ‘min’.

‘uniform(min,max)’ is rounding fractional numbers in ‘max’.

Calling uniform with arguments min and max such that min > max will fail and return the following error:

‘uniform(min,max)’ has ‘min’ greater than ‘max+1’.

Recipes and best practices

uniform and its variants can be used as building blocks to craft more complex functions by parts:

// This function maps [0,5] to 1, [6,8] to 2 and [9,+∞] to 3
f = uniform(5) + 2 * uniform(6, 8) + 3 * uniform.right(9)
show scalar "f" a3b4 with f

See also

User Contributed Notes
0 notes + add a note