當前位置: 首頁>>代碼示例>>Python>>正文


Python random.paretovariate方法代碼示例

本文整理匯總了Python中random.paretovariate方法的典型用法代碼示例。如果您正苦於以下問題:Python random.paretovariate方法的具體用法?Python random.paretovariate怎麽用?Python random.paretovariate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在random的用法示例。


在下文中一共展示了random.paretovariate方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_random_text

# 需要導入模塊: import random [as 別名]
# 或者: from random import paretovariate [as 別名]
def create_random_text(strs,slen,alpha):
    '''
    Create strs number of strings with length of slen 
    Use pareto distribution to pull randomly from 4 different groups 
    if Alpha is large (>10) get almost 100% letters, 
    if Alpha is smaller (1..5) get mixture of letters, numbers and special chars
    See https://en.wikipedia.org/wiki/Pareto_distribution
    '''
    s = []
    chrs = sorted(list(Morsecode))
    groups =[[29,55],[12,22],[0,11],[55,60]] #letters 29-55, numbers 12-22
    for i in range(strs):
        for j in range(slen):
            val = paretovariate(alpha)-1 #pareto distribution 
            gn = int((val, 3)[val > 3])  # select the group characters are pulled from
            s += chrs[randrange(groups[gn][0],groups[gn][1])] #select random char from group 
        s += ' '
    return ''.join(s) 
開發者ID:ag1le,項目名稱:LSTM_morse,代碼行數:20,代碼來源:LSTM.py

示例2: get_dist

# 需要導入模塊: import random [as 別名]
# 或者: from random import paretovariate [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

示例3: fill_data

# 需要導入模塊: import random [as 別名]
# 或者: from random import paretovariate [as 別名]
def fill_data(conn):
    async with conn.begin():
        for name in random.sample(names, len(names)):
            uid = await conn.scalar(
                users.insert().values(name=name, birthday=gen_birthday()))
            emails_count = int(random.paretovariate(2))
            for num in random.sample(range(10000), emails_count):
                is_private = random.uniform(0, 1) < 0.8
                await conn.execute(emails.insert().values(
                    user_id=uid,
                    email='{}+{}@gmail.com'.format(name, num),
                    private=is_private)) 
開發者ID:aio-libs,項目名稱:aiopg,代碼行數:14,代碼來源:sa.py

示例4: pareto_sequence

# 需要導入模塊: import random [as 別名]
# 或者: from random import paretovariate [as 別名]
def pareto_sequence(n,exponent=1.0):
    """
    Return sample sequence of length n from a Pareto distribution.
    """
    return [random.paretovariate(exponent) for i in range(n)] 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:7,代碼來源:random_sequence.py

示例5: powerlaw_sequence

# 需要導入模塊: import random [as 別名]
# 或者: from random import paretovariate [as 別名]
def powerlaw_sequence(n,exponent=2.0):
    """
    Return sample sequence of length n from a power law distribution.
    """
    return [random.paretovariate(exponent-1) for i in range(n)] 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:7,代碼來源:random_sequence.py

示例6: powerlaw_sequence

# 需要導入模塊: import random [as 別名]
# 或者: from random import paretovariate [as 別名]
def powerlaw_sequence(n, exponent=2.0):
    """
    Return sample sequence of length n from a power law distribution.
    """
    return [random.paretovariate(exponent - 1) for i in range(n)] 
開發者ID:aws-samples,項目名稱:aws-kube-codesuite,代碼行數:7,代碼來源:random_sequence.py


注:本文中的random.paretovariate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。