uniform(number)

uniform(number), function

def pure uniform(n: number): zedfunc
1

Returns the function f:k1(k[0,n])f: k \mapsto \bold{1}(k \in [0, n]), that maps an integer kk to 11 if k[0,n]k \in [0,n] and 00 otherwise.
The argument n must be an integer or the function fails.

Example

show scalar "" a1b2 with uniform(5)
1

Errors

Calling uniform with a non-integer argument will fail and return the following error:

‘uniform(n)’ is rounding fractional numbers.

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 and [6,+∞] to 2
f1 = uniform(5) + 2 * uniform.right(6)
show scalar "f1" a3b4 with f1
1 2 3

See also

User Contributed Notes
0 notes + add a note