コード例 #1
0
def input_init(personcnt):
    # print random.power([0.1,1,10,9],[10,4])
    # print random.pareto([0.1,1,10,9],[100,4],type=int)
    # print random.pareto(3,100)
    # print random.pareto(30,100)

    ma_fans = (random.pareto(0.4, personcnt)
               ) * 10 + 1  #(random.randint(30,100000000,personcnt))*10+1#
    cbm_frs = random.pareto(0.5, personcnt) * 10 + 1
    inv_mention = random.power(1, personcnt) * 10 + 1  #randint(0,2,personcnt)#
    act_micorcnt = random.pareto(3, personcnt) * 10 + 1
    # plothem(ma_fans,cbm_frs,inv_mention,act_micorcnt)
    return [ma_fans, cbm_frs, inv_mention, act_micorcnt]
コード例 #2
0
 def randomlist(self,mode=1,size=1000,low=0,high=100):
     "generate a list followed given distribution"
     "IN:distribution model code which refer to randomlist method; sequence size; sequence range"
     "OUT:a sequence followed distribution like"
     x = []
     if mode == 1:        
         x = random.randint(low,high,size=size)
     if mode == 2:
         x = map(float,random.normal(loc=(low+high)/2.0, scale=(high-low)/6.0, size=size))
     if mode == 3:
         x = map(long,random.exponential(scale=1, size=size)+low)
     if mode == 4:
         x = map(long,random.pareto(1,size=size)+low)
     if mode == 5:
         x = map(long,random.poisson(lam=(low+high)/2.0, size=size))    
 #     x = random.choice(x,size=100)    
     return x