MCPcopy Index your code
hub / github.com/python/cpython / uniform

Method uniform

Lib/random.py:500–509  ·  view source on GitHub ↗

Get a random number in the range [a, b) or [a, b] depending on rounding. The mean (expected value) and variance of the random variable are: E[X] = (a + b) / 2 Var[X] = (b - a) ** 2 / 12

(self, a, b)

Source from the content-addressed store, hash-verified

498 ## -------------------- real-valued distributions -------------------
499
500 def uniform(self, a, b):
501 """Get a random number in the range [a, b) or [a, b] depending on rounding.
502
503 The mean (expected value) and variance of the random variable are:
504
505 E[X] = (a + b) / 2
506 Var[X] = (b - a) ** 2 / 12
507
508 """
509 return a + (b - a) * self.random()
510
511 def triangular(self, low=0.0, high=1.0, mode=None):
512 """Triangular distribution.

Callers 11

test_zeroinputsMethod · 0.95
test_floatMethod · 0.80
test_doubled_dataMethod · 0.80
test_doubled_dataMethod · 0.80
test_iter_list_sameMethod · 0.80
subMethod · 0.80
testDistMethod · 0.80
subMethod · 0.80

Calls 1

randomMethod · 0.45

Tested by 11

test_zeroinputsMethod · 0.76
test_floatMethod · 0.64
test_doubled_dataMethod · 0.64
test_doubled_dataMethod · 0.64
test_iter_list_sameMethod · 0.64
subMethod · 0.64
testDistMethod · 0.64
subMethod · 0.64