Navigation :
random.uniform
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).
a: the inclusive lower bound.
b: the exclusive upper bound (must be at least a).
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 |