当前位置: 首页>>代码示例>>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;未经允许,请勿转载。