当前位置: 首页>>代码示例>>Python>>正文


Python random.gammavariate方法代码示例

本文整理汇总了Python中random.gammavariate方法的典型用法代码示例。如果您正苦于以下问题:Python random.gammavariate方法的具体用法?Python random.gammavariate怎么用?Python random.gammavariate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在random的用法示例。


在下文中一共展示了random.gammavariate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_zeroinputs

# 需要导入模块: import random [as 别名]
# 或者: from random import gammavariate [as 别名]
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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:20,代码来源:test_random.py

示例2: test_endpoints_run

# 需要导入模块: import random [as 别名]
# 或者: from random import gammavariate [as 别名]
def test_endpoints_run(deferred_endpoint):
    '''Test that each endpoint is callable.
    
    This takes a very, very long time in total (10-20 minutes) because we don't
    want to barrage the NBA site with requests.'''
    # Delay briefly
    wait = random.gammavariate(alpha=9, beta=0.4)
    time.sleep(wait)
    # Call the API.
    try:
        response = deferred_endpoint()
    except json.decoder.JSONDecodeError:
        endpoint_class = deferred_endpoint.endpoint_class
        msg = 'Unable to decode response for {}'.format(endpoint_class)
        pytest.fail(msg=msg)
    # We want to hang onto all the responses so we don't need to re-retrieve
    # them later.
    cached_eps.append(response) 
开发者ID:swar,项目名称:nba_api,代码行数:20,代码来源:test_endpoint_responses_valid.py

示例3: get_dist

# 需要导入模块: import random [as 别名]
# 或者: from random import gammavariate [as 别名]
def get_dist(d):
    return {
        'randrange': random.randrange, # start, stop, step
        'randint': random.randint, # a, b
        'random': random.random,
        'uniform': random, # a, b
        'triangular': random.triangular, # low, high, mode
        'beta': random.betavariate, # alpha, beta
        'expo': random.expovariate, # lambda
        'gamma': random.gammavariate, # alpha, beta
        'gauss': random.gauss, # mu, sigma
        'lognorm': random.lognormvariate, # mu, sigma
        'normal': random.normalvariate, # mu, sigma
        'vonmises': random.vonmisesvariate, # mu, kappa
        'pareto': random.paretovariate, # alpha
        'weibull': random.weibullvariate # alpha, beta
    }.get(d) 
开发者ID:cerob,项目名称:slicesim,代码行数:19,代码来源:__main__.py

示例4: _fix

# 需要导入模块: import random [as 别名]
# 或者: from random import gammavariate [as 别名]
def _fix(self):
        return int(round(random.gammavariate(self.alpha, self.beta))) 
开发者ID:medbenali,项目名称:CyberScan,代码行数:4,代码来源:volatile.py

示例5: test_gammavariate_errors

# 需要导入模块: import random [as 别名]
# 或者: from random import gammavariate [as 别名]
def test_gammavariate_errors(self):
        # Both alpha and beta must be > 0.0
        self.assertRaises(ValueError, random.gammavariate, -1, 3)
        self.assertRaises(ValueError, random.gammavariate, 0, 2)
        self.assertRaises(ValueError, random.gammavariate, 2, 0)
        self.assertRaises(ValueError, random.gammavariate, 1, -3) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_random.py

示例6: rand_student_t

# 需要导入模块: import random [as 别名]
# 或者: from random import gammavariate [as 别名]
def rand_student_t(df, mu=0, std=1):
    """
    return random number distributed by student's t distribution with
    `df` degrees of freedom with the specified mean and standard deviation.
    """

    x = random.gauss(0, std)
    y = 2.0*random.gammavariate(0.5 * df, 2.0)
    return x / (math.sqrt(y / df)) + mu 
开发者ID:rlabbe,项目名称:filterpy,代码行数:11,代码来源:stats.py

示例7: poisson_latency

# 需要导入模块: import random [as 别名]
# 或者: from random import gammavariate [as 别名]
def poisson_latency(latency):
    return lambda: 1 + int(random.gammavariate(1, 1) * latency) 
开发者ID:ethereum,项目名称:research,代码行数:4,代码来源:simulator.py


注:本文中的random.gammavariate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。