In the name of God;
Testlib has nice random functions, here I want to suggest some other ones. The first and the second random functions are available in testlib, but the rest are not.
- $$$\text{rnd.next(l, r)}$$$, it will return a random number in range $$$l$$$ to $$$r$$$ with equal weights :
- $$$\text{rnd.wnext(l, r, w)}$$$, it will return a random number in range $$$l$$$ to $$$r$$$ with monotonically increasing/decreasing weights depending on $$$w$$$ :
If $$$w = 0$$$ then it will be equal to $$$\text{rnd.next(l, r)}$$$.
If $$$w > 0$$$ :
If $$$w < 0$$$ :
- $$$\text{rnd.cnext(l, r, c)}$$$, it will return a random number in range $$$l$$$ to $$$r$$$ :
If $$$c = 0$$$ then it will be equal to $$$\text{rnd.next(l, r)}$$$
If $$$w > 0$$$ :
If $$$w < 0$$$ :
4, $$$\text{rnd.cwnext(l, r, c, w)}$$$, it will return a random number in range $$$l$$$ to $$$r$$$ like $$$\text{rnd.cnext{l, r, c}$$$, but is not centered around $$$\frac {r+l} 2$$$ :