Natural random number(自然随机数(Natural random number))¶
Supported in: Batch, Faster, Streaming
Returns a random natural number. This is not deterministic and will not produce the same result on repeated builds, even when using a seed.
Expression categories: Numeric
Declared arguments¶
- Max value: Upper bound of the random value to be generated (exclusive).
Literal\ - Min value: Lower bound of the random value to be generated (inclusive).
Literal\ - optional Seed: Adding a seed means that the random numbers will be generated from same sequence at each build. If you want true random numbers this should not be supplied. A seed will not produce fully deterministic results since compute may run distributed and the order in which random numbers are pulled for rows is not guaranteed.
Literal\
Output type: Long
Examples¶
Example 1: Base case¶
Description: The only natural number between 10 (inclusive) and 11 (exclusive) is 10.
Argument values:
- Max value: 11
- Min value: 10
- Seed: null
Output: 10
Example 2: Base case¶
Description: Generaring a number between 10 (inclusive) and 15 (exclusive) with seed 1.
Argument values:
- Max value: 15
- Min value: 10
- Seed: 1
Output: 13
中文翻译¶
自然随机数(Natural random number)¶
支持:批处理(Batch)、快速处理(Faster)、流处理(Streaming)
返回一个自然随机数。该函数不具有确定性,即使在指定种子(seed)的情况下,重复构建也不会产生相同的结果。
表达式类别: 数值型(Numeric)
声明的参数(Declared arguments)¶
- 最大值(Max value): 待生成随机值的上限(不包含)。
字面量\<Long> - 最小值(Min value): 待生成随机值的下限(包含)。
字面量\<Long> - 可选 种子(Seed): 添加种子意味着每次构建时将从相同的序列生成随机数。如果需要真正的随机数,则不应提供此参数。种子不会产生完全确定性的结果,因为计算可能以分布式方式运行,且为行提取随机数的顺序无法保证。
字面量\<Long>
输出类型: Long
示例(Examples)¶
示例1:基本情况¶
描述: 在10(包含)到11(不包含)之间唯一的自然数是10。
参数值:
- 最大值: 11
- 最小值: 10
- 种子: null
输出: 10
示例2:基本情况¶
描述: 使用种子1生成一个介于10(包含)到15(不包含)之间的数字。
参数值:
- 最大值: 15
- 最小值: 10
- 种子: 1
输出: 13