Navigation :
uniform(number)
def pure uniform(n: number): zedfunc
1
Returns the function f:k↦1(k∈[0,n]), that maps an integer k to 1 if k∈[0,n] and 0 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