當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。