1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use Rng;
/// Generate a non-uniformly distributed random integer in the range [0, n).
/// The distribution is controlled by a bias parameter, which makes smaller integers more likely to be generated.
/// 生成一个在 [0, n) 区间内非均匀分布的随机整数。
/// 通过一个偏向参数 (bias) 来控制分布,使得数值越小的整数生成的概率越高。
///
/// # Arguments
///
/// * `n` - The upper bound (exclusive) for the random number. Must be a positive integer greater than 0.
/// - `n`: 随机数上限(不包含),必须是大于0的正整数。
/// * `bias` - The bias strength parameter. Must be a positive number.
/// - `bias > 1`: Smaller numbers are more likely. The larger the bias, the more skewed the result is towards 0.
/// - `bias = 1`: Approaches a standard uniform distribution.
/// - `0 < bias < 1`: Larger numbers are more likely.
/// - `bias`: 偏向强度参数,必须是正数。
/// - `bias > 1`: 数值越小概率越高。bias越大,结果越偏向0。
/// - `bias = 1`: 接近标准均匀分布。
/// - `0 < bias < 1`: 数值越大概率越高。
///
/// # Returns
///
/// A random integer in the [0, n) range.
/// 返回一个在 [0, n) 区间内的随机整数。