Python random 模块,betavariate() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用random.betavariate()

项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_zeroinputs(self):
        # Verify that distributions can handle a series of zero inputs'
        g = random.Random()
        x = [g.random() for i in range(50)] + [0.0]*5
        g.random = x[:].pop; g.uniform(1,10)
        g.random = x[:].pop; g.paretovariate(1.0)
        g.random = x[:].pop; g.expovariate(1.0)
        g.random = x[:].pop; g.weibullvariate(1.0, 1.0)
        g.random = x[:].pop; g.vonmisesvariate(1.0, 1.0)
        g.random = x[:].pop; g.normalvariate(0.0, 1.0)
        g.random = x[:].pop; g.gauss(0.0, 1.0)
        g.random = x[:].pop; g.lognormvariate(0.0, 1.0)
        g.random = x[:].pop; g.vonmisesvariate(0.0, 1.0)
        g.random = x[:].pop; g.gammavariate(0.01, 1.0)
        g.random = x[:].pop; g.gammavariate(1.0, 1.0)
        g.random = x[:].pop; g.gammavariate(200.0, 1.0)
        g.random = x[:].pop; g.betavariate(3.0, 3.0)
        g.random = x[:].pop; g.triangular(0.0, 1.0, 1.0/3.0)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_zeroinputs(self):
        # Verify that distributions can handle a series of zero inputs'
        g = random.Random()
        x = [g.random() for i in range(50)] + [0.0]*5
        g.random = x[:].pop; g.uniform(1,10)
        g.random = x[:].pop; g.paretovariate(1.0)
        g.random = x[:].pop; g.expovariate(1.0)
        g.random = x[:].pop; g.weibullvariate(1.0, 1.0)
        g.random = x[:].pop; g.vonmisesvariate(1.0, 1.0)
        g.random = x[:].pop; g.normalvariate(0.0, 1.0)
        g.random = x[:].pop; g.gauss(0.0, 1.0)
        g.random = x[:].pop; g.lognormvariate(0.0, 1.0)
        g.random = x[:].pop; g.vonmisesvariate(0.0, 1.0)
        g.random = x[:].pop; g.gammavariate(0.01, 1.0)
        g.random = x[:].pop; g.gammavariate(1.0, 1.0)
        g.random = x[:].pop; g.gammavariate(200.0, 1.0)
        g.random = x[:].pop; g.betavariate(3.0, 3.0)
        g.random = x[:].pop; g.triangular(0.0, 1.0, 1.0/3.0)
项目:bpy_lambda    作者:bcongdon    | 项目源码 | 文件源码
def skewedGauss(mu, sigma, bounds, upperSkewed=True):
    raw = gauss(mu, sigma)

    # Quicker to check an extra condition than do unnecessary math. . . .
    if raw < mu and not upperSkewed:
        out = ((mu - bounds[0]) / (3 * sigma)) * raw + ((mu * (bounds[0] - (mu - 3 * sigma))) / (3 * sigma))
    elif raw > mu and upperSkewed:
        out = ((mu - bounds[1]) / (3 * -sigma)) * raw + ((mu * (bounds[1] - (mu + 3 * sigma))) / (3 * -sigma))
    else:
        out = raw

    return out


# @todo create a def for generating an alpha and beta for a beta distribution
#   given a mu, sigma, and an upper and lower bound.  This proved faster in
#   profiling in addition to providing a much better distribution curve
#   provided multiple iterations happen within this function; otherwise it was
#   slower.
#   This might be a scratch because of the bounds placed on mu and sigma:
#
#   For alpha > 1 and beta > 1:
#   mu^2 - mu^3           mu^3 - mu^2 + mu
#   ----------- < sigma < ----------------
#      1 + mu                  2 - mu
#
##def generateBeta(mu, sigma, scale, repitions=1):
##    results = []
##
##    return results

# Creates rock objects:
项目:gitcha-scripts    作者:yeonghoey    | 项目源码 | 文件源码
def new_item_count():
    return int(random.betavariate(0.3, 0.5) * 100)
项目:zippy    作者:securesystemslab    | 项目源码 | 文件源码
def sample(self):
        return random.betavariate(self.alpha, self.beta)
项目:ouroboros    作者:pybee    | 项目源码 | 文件源码
def test_betavariate_return_zero(self, gammavariate_mock):
        # betavariate() returns zero when the Gamma distribution
        # that it uses internally returns this same value.
        gammavariate_mock.return_value = 0.0
        self.assertEqual(0.0, random.betavariate(2.71828, 3.14159))
项目:Python-iBeacon-Scan    作者:NikNitro    | 项目源码 | 文件源码
def sample(self):
        return random.betavariate(self.alpha, self.beta)
项目:iota    作者:amaneureka    | 项目源码 | 文件源码
def Random(self):
        """Generates a random variate from this distribution."""
        return random.betavariate(self.alpha, self.beta)
项目:iota    作者:amaneureka    | 项目源码 | 文件源码
def Random(self):
        """Generates a random variate from this distribution."""
        return random.betavariate(self.alpha, self.beta)
项目:kbe_server    作者:xiaohaoppy    | 项目源码 | 文件源码
def test_betavariate_return_zero(self, gammavariate_mock):
        # betavariate() returns zero when the Gamma distribution
        # that it uses internally returns this same value.
        gammavariate_mock.return_value = 0.0
        self.assertEqual(0.0, random.betavariate(2.71828, 3.14159))
项目:ThinkX    作者:AllenDowney    | 项目源码 | 文件源码
def Random(self):
        """Generates a random variate from this distribution."""
        return random.betavariate(self.alpha, self.beta)
项目:ThinkX    作者:AllenDowney    | 项目源码 | 文件源码
def Random(self):
        """Generates a random variate from this distribution."""
        return random.betavariate(self.alpha, self.beta)
项目:ThinkX    作者:AllenDowney    | 项目源码 | 文件源码
def Random(self):
        """Generates a random variate from this distribution."""
        return random.betavariate(self.alpha, self.beta)
项目:HyperStream    作者:IRC-SPHERE    | 项目源码 | 文件源码
def _execute(self, sources, alignment_stream, interval):
        if alignment_stream is None:
            raise ToolExecutionError("Alignment stream expected")

        for ti, _ in alignment_stream.window(interval, force_calculation=True):
            yield StreamInstance(ti, random.betavariate(alpha=self.alpha, beta=self.beta))