Rand Range
Problem
UE4's "Random Integer in Range" and "Random Float in Range" functions do not produce a uniform distribution, and some values are never selected when the range is greater than 2^23.
The value '16,777,216' (or 2^24) is a sweet spot where it's easy to see that the generation is non uniform, because the random integers are never odd. See for yourself in the example map's LV_RandRangeImprovements level, or simply add this operation to the blueprint of your choice:
This operation will always return true when using a Random Stream, regardless of the seed.
The float implementation has the same issue:
This operation will always return true when using a Random Stream, regardless of the seed.
It's worse with floats since there are many more missing decimal values in between the even numbers!
The modulo 2 operation returns the remainder after dividing by 2: this would be 0 for all even numbers and 1 for all odd numbers.
Solution
Stoch's "Random Integer in Range" and "Random Float in Range" functions always produce a uniform distribution. Moreover, Stoch's function can produce values in the full range of the type (int32, int64, or float). Stoch's random range implementations use rejection sampling and are derived from the Boost Library.
See the level LV_RandRangeImprovements from the example map for demonstrations.
Unreal's functions trade-off speed for uniformity. This may be acceptable for some games which don't need larger ranges. The non-uniformity becomes most apparent at ranges larger than 8,388,608.