uniformR is:exact

Generates a value uniformly distributed over the provided range, which is interpreted as inclusive in the lower and upper bound.
  • uniformR (1 :: Int, 4 :: Int) generates values uniformly from the set <math>
  • uniformR (1 :: Float, 4 :: Float) generates values uniformly from the set <math>
The following law should hold to make the function always defined:
uniformR (a, b) = uniformR (b, a)
This is a pure version of uniformRM.

Examples

>>> import System.Random

>>> let pureGen = mkStdGen 137

>>> uniformR (1 :: Int, 4 :: Int) pureGen
(4,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})
You can use type applications to disambiguate the type of the generated numbers:
>>> :seti -XTypeApplications

>>> uniformR @Int (1, 4) pureGen
(4,StdGen {unStdGen = SMGen 11285859549637045894 7641485672361121627})
Generate single uniformly distributed random variable in a given range.
  • For integral types inclusive range is used.
  • For floating point numbers range (a,b] is used if one ignores rounding errors.
The uniform distribution over the provided interval.
>>> sample (uniformR (0, 1)) gen
0.44984153252922365
Generate a uniformly distributed random vairate in the given range.
  • Use inclusive range for integral types.
  • Use (a,b] range for floating types.
Uniform between two values
Endlessly produce anything that's Variate from a uniform distribution, within some given range of values.
  • For integral types, inclusive range is used.
  • For floating types, (a,b] is used.