Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to statistics.py #47

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Prev Previous commit
Next Next commit
Changed degree_dist and degree_dist_binned to match previous API.
tlarock committed Mar 26, 2019
commit b7f0cb803d1ce8ddb5b9c3c723d1a5cbfadf3719
8 changes: 4 additions & 4 deletions pathpy/algorithms/statistics.py
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ def mean_degree(network, degree='degree'):
return _np.mean([network.nodes[x][degree] for x in network.nodes])


def degree_hist(network, degree='degree'):
def degree_dist(network, degree='degree'):
r"""Calculates the (in/out)-degree histogram of a directed or undirected network.

Parameters
@@ -120,7 +120,7 @@ def degree_moment(network, k, degree='degree'):
network: Network
The network in which to calculate the k-th moment of the degree distribution
"""
p_k = degree_hist(network, degree)
p_k = degree_dist(network, degree)
mom = 0
for x in p_k:
mom += x**k * p_k[x]
@@ -173,7 +173,7 @@ def generating_func(network, x, degree='degree'):
assert isinstance(x, (float, list, _np.ndarray)), \
'Argument can only be float, list or numpy.ndarray'

p_k = degree_hist(network, degree)
p_k = degree_dist(network, degree)

if isinstance(x, float):
x_range = [x]
@@ -232,7 +232,7 @@ def get_bins(values, num_bins, log_bins=False):
return bins


def degree_distribution(network, num_bins=30, degree='degree', log_bins=True, is_pmf=True):
def degree_dist_binned(network, num_bins=30, degree='degree', log_bins=True, is_pmf=True):
'''
Take a pathpy.network object and return the degree distribution.