random.uniform

random.uniform, function

def autodiff pure random.uniform(): number
def autodiff pure random.uniform(a: number, b: number): number

Draws a deviate from a uniform distribution. The zero-argument overload samples over [0, 1).

Examples

montecarlo 10000 with
  x = random.uniform()
  sample avg0 = avg(x)

show scalar "Average sample [0,1)" with avg0

This outputs the following scalar:

Average sample [0,1)
0.4986499
montecarlo 10000 with
  y = random.uniform(2, 4)
  sample avg1 = avg(y)

show scalar "Average sample [2,4)" with avg1

This outputs the following scalar:

Average sample [2,4)
3.002024
User Contributed Notes
0 notes + add a note