Documentation ¶
Overview ¶
Package randx contains random-related utilities. It means to be a complement to the standard math/rand package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandomIntWeight ¶
RandomIntWeight chooses an index randomly using the listed non-negative relative weights.
The default Rand of math/rand package is used for random data.
Implementation guarantees to return an integer in the range of [0..len(weights)). If no weight is provided or they add up to 0, -1 is returned. Behavior for negative weights is undefined.
func RandomWeight ¶
RandomWeight chooses an index randomly using the listed (non-negative) probabilities as weights. Weights must add up to 1.
The default Rand of math/rand package is used for random data.
Implementation guarantees to return an integer in the range of [0..len(weights)). If weights don't add up to 1, -1 may be returned.
Types ¶
This section is empty.