# Python random.paretovariate() Examples

The following are 6 code examples of random.paretovariate(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module , or try the search function .
Example #1
 Source File: LSTM.py    From LSTM_morse with MIT License 6 votes
```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) ```
Example #2
 Source File: __main__.py    From slicesim with MIT License 6 votes
```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) ```
Example #3
 Source File: sa.py    From aiopg with BSD 2-Clause "Simplified" License 5 votes
```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)) ```
Example #4
 Source File: random_sequence.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes
```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)] ```
Example #5
 Source File: random_sequence.py    From qgisSpaceSyntaxToolkit with GNU General Public License v3.0 5 votes
```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)] ```
Example #6
 Source File: random_sequence.py    From aws-kube-codesuite with Apache License 2.0 5 votes
```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)] ```