Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Use <a href="http://arxiv.org/pdf/1011.1533.pdf" rel="noreferrer">log binning</a> (<a href="http://arxiv.org/pdf/0706.1062.pdf" rel="noreferrer">see also</a>). Here is code to take a <code>Counter</code> object representing a histogram of degree values and log-bin the distribution to produce a sparser and smoother distribution.</p> <pre><code>import numpy as np def drop_zeros(a_list): return [i for i in a_list if i&gt;0] def log_binning(counter_dict,bin_count=35): max_x = log10(max(counter_dict.keys())) max_y = log10(max(counter_dict.values())) max_base = max([max_x,max_y]) min_x = log10(min(drop_zeros(counter_dict.keys()))) bins = np.logspace(min_x,max_base,num=bin_count) # Based off of: http://stackoverflow.com/questions/6163334/binning-data-in-python-with-scipy-numpy bin_means_y = (np.histogram(counter_dict.keys(),bins,weights=counter_dict.values())[0] / np.histogram(counter_dict.keys(),bins)[0]) bin_means_x = (np.histogram(counter_dict.keys(),bins,weights=counter_dict.keys())[0] / np.histogram(counter_dict.keys(),bins)[0]) return bin_means_x,bin_means_y </code></pre> <p>Generating a classic scale-free network in <code>NetworkX</code> and then plotting this:</p> <pre><code>import networkx as nx ba_g = nx.barabasi_albert_graph(10000,2) ba_c = nx.degree_centrality(ba_g) # To convert normalized degrees to raw degrees #ba_c = {k:int(v*(len(ba_g)-1)) for k,v in ba_c.iteritems()} ba_c2 = dict(Counter(ba_c.values())) ba_x,ba_y = log_binning(ba_c2,50) plt.xscale('log') plt.yscale('log') plt.scatter(ba_x,ba_y,c='r',marker='s',s=50) plt.scatter(ba_c2.keys(),ba_c2.values(),c='b',marker='x') plt.xlim((1e-4,1e-1)) plt.ylim((.9,1e4)) plt.xlabel('Connections (normalized)') plt.ylabel('Frequency') plt.show() </code></pre> <p>Produces the following plot showing the overlap between the "raw" distribution in blue and the "binned" distribution in red.</p> <p><img src="https://i.imgur.com/o8piIas.png" alt="Comparison between raw and log-binned"></p> <p>Thoughts on how to improve this approach or feedback if I've missed something obvious are welcome.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload