uniform(number)
uniform(number), function
def pure uniform(n: number): zedfunc
Returns the function $f: k \mapsto \bold{1}(k \in [0, n])$, that maps an integer $k$ to $1$ if $k \in [0,n]$ and $0$ otherwise.
The argument n
must be an integer or the function fails.
n
: an integer
Example
show scalar "" a1b2 with uniform(5)
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
See also
- uniform disambiguation
- uniform(number, number)
- uniform.left
- uniform.right
- random.uniform to generate uniform random variables