def DR_histogram(X,Y,Xr,Yr,distance,th_min,th_max,theta_bins,cat_number=3):
    n_points=len(X)
    #Xmin=1.0*np.floor( np.amin(X) )
    #Xmax=1.0*np.ceil( np.amax(X) )
    #Ymin=1.0*np.floor( np.amin(Y) )
    #Ymax=1.0*np.ceil( np.amax(Y) )
    

    #Xr= Xmin +  ( Xmax - Xmin )*np.random.random_sample(n_points*cat_number)
    #Yr=Ymin +   ( Ymax - Ymin )*np.random.random_sample(n_points*cat_number)
    d_arr=[]
    print "number of LAEs=" + str(n_points)
    for m in range(cat_number): 
        for i in range(n_points):
	    if(i%100==0):
            	print "LAE_"+str(i)
            for j in range(n_points):
                d=( X[i] - Xr[j + n_points*m] )*( X[i] - Xr[j + n_points*m] ) + ( Y[i] - Yr[j + n_points*m] )*( Y[i] - Yr[j + n_points*m] )
                d=np.sqrt(d)/distance
                d_arr=np.append(d_arr,d)
    theta=206265*d_arr 
    
    DR,bins=np.histogram(theta,bins=theta_bins, range=(th_min,th_max))
    
    N=1.0*n_points*(n_points)
    N=(N*cat_number)            
    DR=DR/N
    
    return DR,bins
def RR_histogram(X,Y,Xr,Yr,distance,th_min,th_max,theta_bins,cat_number=3):
    
    n_points=len(X)
    #Xmin=1.0*np.floor( np.amin(X) )
    #Xmax=1.0*np.ceil( np.amax(X) )
    #Ymin=1.0*np.floor( np.amin(Y) )
    #Ymax=1.0*np.ceil( np.amax(Y) )
    

    #Xr= Xmin +  ( Xmax - Xmin )*np.random.random_sample(n_points*cat_number)
    #Yr=Ymin +   ( Ymax - Ymin )*np.random.random_sample(n_points*cat_number)
    d_arr=[]

    for m in range(cat_number):
        print "random cat=",m
        for i in range(n_points):
            for j in range(i+1,n_points):
                
                d=(Xr[i + n_points*m ] - Xr[j + n_points*m ])*(Xr[i + n_points*m ] - Xr[j + n_points*m ]) + (Yr[i + n_points*m ] - Yr[j + n_points*m ])*(Yr[i + n_points*m ] - Yr[j + n_points*m ])
                d=np.sqrt(d)/distance
                d_arr=np.append(d_arr,d)
                
    theta=206265*d_arr 
    
    RR,bins=np.histogram(theta,bins=theta_bins, range=(th_min,th_max))
    
    N=1.0*n_points*(1.0*n_points-1.0)/2.0
    N=N*cat_number
    RR=RR/N            
    
    return RR,bins
def DD_histogram(X,Y,distance,th_min,th_max,theta_bins):

    n_points=len(X)
    d_arr=[]
    print "number of LAEs=" + str(n_points)
    for i in range(n_points):
        
        if(i%100==0):
            print "LAE_"+str(i)
        for j in range(i+1,n_points):
            d=(X[i] - X[j])*(X[i] - X[j]) + (Y[i] - Y[j])*(Y[i] - Y[j])
            d=np.sqrt(d)/distance
            d_arr=np.append(d_arr,d)
            
            
    theta=206265.0*d_arr         
    
    
    DD,bins=np.histogram(theta,bins=theta_bins, range=(th_min,th_max))
    
    N=1.0*n_points*(1.0*n_points-1.0)/2.0
    DD=DD/N
    
    return DD,bins
示例#4
0
#plt.figure()
#p = plt.imshow(board2.T, cmap = plt.cm.gist_yarg_r, vmin=0, vmax=n, origin = 'lower',  extent = [0, phi, 0, Z], aspect='auto')
#fig = plt.gcf()
#plt.clim()
#plt.colorbar()
##plt.title('GiantComponent Heatmap2 - %d, %d, %d, %f, %f, %f, %d, %d, %d, %d' %(n, Z, Z_min, rho, phi, sigma, MAX_Steps_to_cascade, res, resPhi, NO_realization_at_each_meandegree_step))
#plt.title('GiantComponent Heatmap')
#plt.ylabel('Mean degree')
#plt.xlabel('Mean threshold')
#plt.savefig(figure_path + Filename_str+ 'GiantComponent-Homophily.pdf')



plt.figure()
hist, bins = np.histogram(node_Phi_data, bins = 50)
width = 0.7*(bins[1]-bins[0])
center = (bins[:-1] + bins[1:])/2
plt.title('Threshold distribution after homophily update')
plt.xlabel('Threshold value')
plt.ylabel('Frequency')
plt.bar(center, hist, align = 'center', width = width)
plt.savefig(figure_path + Filename_str+ 'Histogram-Homophily.pdf')